[NASM] macro - where is mistake?

From: bolsa (bolsam1_at_o2.pl)
Date: 05/18/04

  • Next message: Woody: "Re: DirectX in HLA"
    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:


  • Next message: Woody: "Re: DirectX in HLA"

    Relevant Pages

    • Re: Separating evaluation and compilation environments.
      ... compilation and evaluation environments long before that. ... a baz definition and expanding out the foo macro forces you to recompile ... that definition if you redefine foo but intend to use baz again. ...
      (comp.lang.lisp)
    • Re: Question about compilation/evaluation environments
      ... I guess it depends on what you mean by evaluating some code. ... In this case, the form is the macro function, aka macro ... >> expander, aka expansion function... ... compilation of function and macro definitions. ...
      (comp.lang.lisp)
    • Re: Why doesnt Lisp automatically differentiate functions and macros?
      ... evaluation, compilation, and run-time environments. ... Note that because the CLHS forbids macro functions from ... Common Lisp macro functions *can* do system calls at macro ... create/modify global data at compile time. ...
      (comp.lang.lisp)
    • CMUCL optimizer [was Re: Sacla loop: a new loop implementation]
      ... explore type information at macroexpansion time to decide the macro ... (defmethod generic-iter ((obj symbol) ... In order to measure the compilation and load time I decided to create ...
      (comp.lang.lisp)
    • Re: Difference between Macro and Function...
      ... |>between a freemacro and a freefunction ??.... ... | throughout the whole process of compilation, ... to exist through the linking or execution phases. ... Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org ...
      (comp.lang.c)