[NASM] macro - where is mistake?
From: bolsa (bolsam1_at_o2.pl)
Date: 05/18/04
- Previous message: Matt Taylor: "Re: No need to optimize in assembly anymore"
- Next in thread: Frank Kotler: "Re: [NASM] macro - where is mistake?"
- Reply: Frank Kotler: "Re: [NASM] macro - where is mistake?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 18 May 2004 18:26:54 +0000 (UTC)
Here is a piece of my code (don't bother my comments :P):
compilation:
nasm -fobj file.asm -o file.obj
alink file.obj -oEXE -o file.exe
macro has been riped from documentation ... and is not workinkg and i have
no idea why :/
----------------------------------------------------------------------------
-----------------
%macro file_write 2+
[section .data]
%%ptr: db %2
%%endptr:
__SECT__
mov dx, %%ptr ; wskaznik na tekst
mov cx, %%endptr - %%ptr ; dlugosc tekstu
mov bx, %1 ; uchwyt do pliku
mov ah, 0x40 ; zapisz do pliku
int 0x21
%endmacro
........
...start:
mov ax, data ;uzywamy rejestru ax jako posrednika
mov ds, ax
mov ax, stack ;ax - adres segmentu wyznaczonego na segment stos
mov ss, ax ;stos bedzie sie znajdowac pomiedzy ss:0 a ss:sp
mov sp, stacktop ;sp - wskaznik stosu (na koniec)
mov dx, welcome
mov ah, 9
int 0x21
mov dx, filename ; nazwa pliku
mov cx, 0 ; atrybuty
mov ah,0x3c
int 0x21
;file_open 0, filename
mov [filehandle], ax
mov ax,data
mov ds,ax
file_write [filehandle], "hello" ;<<<<------ this
doesn't work for me
........
.......
........
segment data
witaj db "hello", 10,13,'$'
welcome db "Witaj", 10,13,'$'
filename db "plik.in",0
tryb db 0
filehandle resw 01h
[segment .stack stack]
resb 64 ;64 bajty na stos
stacktop:
- Previous message: Matt Taylor: "Re: No need to optimize in assembly anymore"
- Next in thread: Frank Kotler: "Re: [NASM] macro - where is mistake?"
- Reply: Frank Kotler: "Re: [NASM] macro - where is mistake?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|