The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: I_Hate_Assembly on February 23, 2010, 03:53:39 PM

Title: Numerical Value
Post by: I_Hate_Assembly on February 23, 2010, 03:53:39 PM
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
Title: Re: Numerical Value
Post by: dedndave on February 23, 2010, 05:42:24 PM
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
Title: Re: Numerical Value
Post by: I_Hate_Assembly on February 23, 2010, 07:45:03 PM
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.
Title: Re: Numerical Value
Post by: dedndave on February 23, 2010, 08:00:00 PM
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
Title: Re: Numerical Value
Post by: I_Hate_Assembly on February 23, 2010, 08:02:57 PM

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

Thank You
Title: Re: Numerical Value
Post by: dedndave on February 23, 2010, 08:04:42 PM
ok - give me about 15 minutes - then it's nap-time   :bg
Title: Re: Numerical Value
Post by: I_Hate_Assembly on February 23, 2010, 08:09:05 PM
Ok no problem take your time.  :U

Thanks
Title: Re: Numerical Value
Post by: dedndave on February 23, 2010, 08:20:48 PM
give this a try - i did not test it   :P
Title: Re: Numerical Value
Post by: I_Hate_Assembly on February 23, 2010, 08:36:36 PM
I will .. Thanks !  :U
Title: Re: Numerical Value
Post by: I_Hate_Assembly on February 23, 2010, 08:49:56 PM
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
Title: Re: Numerical Value
Post by: dedndave on February 23, 2010, 10:29:49 PM
just add this before you terminate

        mov     ah,0
        int     16h
Title: Re: Numerical Value
Post by: I_Hate_Assembly on February 23, 2010, 10:31:29 PM
I already added the first one before terminating the program.
Does the second one fix the bug ?
Title: Re: Numerical Value
Post by: dedndave on February 23, 2010, 10:35:55 PM
i don't understand the write fault ???
anyways - here is the modified program...
Title: Re: Numerical Value
Post by: I_Hate_Assembly on February 23, 2010, 10:38:22 PM
yes when the program asks for a key to be pressed the message appear
Title: Re: Numerical Value
Post by: dedndave on February 23, 2010, 10:40:07 PM
you'll have to show me the error message - the program runs fine, here
i am using xp pro sp2
Title: Re: Numerical Value
Post by: I_Hate_Assembly on February 23, 2010, 10:44:36 PM
your last prog works fine  :U about the error I received this message
write fault error writing device AUX
abort, retry, fail?

Title: Re: Numerical Value
Post by: dedndave on February 23, 2010, 10:49:47 PM
the AUX device is an alias for the COM1 serial port
you must have the debugger switched in or something
some debuggers may use the AUX device for output
that is a no-no on win2000 or higher OS's without ring 0 privileges
maybe it is a setting in the debugger - not sure
Title: Re: Numerical Value
Post by: I_Hate_Assembly on February 23, 2010, 10:54:34 PM
I am using MASM 16bits under windows xp sp3 and cpu intel E8400.
Title: Re: Numerical Value
Post by: dedndave on February 23, 2010, 11:52:44 PM
well - something is trying to send output to the COM port
Title: Re: Numerical Value
Post by: I_Hate_Assembly on February 23, 2010, 11:56:43 PM
Thank you for you help  :U :thumbu