News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Numerical Value

Started by I_Hate_Assembly, February 23, 2010, 03:53:39 PM

Previous topic - Next topic

I_Hate_Assembly

Hi everyone

I would like to know how I can display a numerical value in this small program.




.model small
.stack 64
.data


.code
xyz PROC NEAR

mov AX, @DATA
mov DS, AX
mov AX ,5
mov BX, 3
call SUM

; un probleme ici
MOV AH,09h
MOV DX,AX
INT 21h

mov ah, 4ch
int 21h

xyz endp

SUM PROC NEAR
ADD AX,BX

RET
SUM endp


end



Thanks in advanceĀ  :U

dedndave

you have a 16-bit binary value
you need to convert that to an ASCII numeric string for display (presumably decimal)
the code depends on whether you want to display signed values (-32768 to 32767) or unsigned (0 to 65535)

lazy method - you could display it in ASCII hexidecimal format and let the reader decide how to interpret it   :P

I_Hate_Assembly

Thank you for your answer  :U

Where can I find the appropriate syntax ?

I looked up for it in the web but I did not find anything standard to do that.

dedndave

there are routines if you search the forum
i have one called ling long kai fang in another thread, but that is 32-bit and it will display huge integers - kind of overkill

let me know whether you want a signed or unsigned routine

I_Hate_Assembly


Let's start with a routine for unsigned, so I can understand it  :P

Thank You

dedndave

ok - give me about 15 minutes - then it's nap-time   :bg

I_Hate_Assembly

Ok no problem take your time.  :U

Thanks

dedndave

give this a try - i did not test it   :P

I_Hate_Assembly


I_Hate_Assembly

I added a line to wait a key press from the keyboard and I get the value but also with a write fault. :P

Thanks !

:bg

dedndave

just add this before you terminate

        mov     ah,0
        int     16h

I_Hate_Assembly

I already added the first one before terminating the program.
Does the second one fix the bug ?

dedndave

i don't understand the write fault ???
anyways - here is the modified program...

I_Hate_Assembly

yes when the program asks for a key to be pressed the message appear

dedndave

you'll have to show me the error message - the program runs fine, here
i am using xp pro sp2