flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Need scan_num macro

Author
Thread Post new topic Reply to topic
log(21



Joined: 09 Jun 2006
Posts: 6
log(21 13 Aug 2006, 02:20
I need a macro that can take a value from a user and convert it into binary.

EX:

PROMPT: 124

>>>124 is then stored in the CX register (or some other register)

Thanks
Post 13 Aug 2006, 02:20
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 13 Aug 2006, 11:09
why macro? i believe you want procedure Wink
Post 13 Aug 2006, 11:09
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 13 Aug 2006, 19:22
Well heres a simple example:
Code:
    prompt rb 8 ; prompt string here, null terminated

    str2lng:

        push ax bx

        xor ax,ax
        xor bx,bx
        xor cx,cx

        mov si,prompt
        mov al,[si]

    @@:

        sub al,'0'
        add cx,ax

        inc si

        mov al,[si]

        cmp al,0
        je @f

        shl cx,1
        mov bx,cx
        shl cx,2
        add cx,bx
        jmp @b

    @@:

        pop bx ax
        ret
    

HTH
Post 13 Aug 2006, 19:22
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.