News:

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

Addition for beginners

Started by Zap, June 13, 2009, 05:43:49 PM

Previous topic - Next topic

Zap

Hi,guys,
i`m studying addition at the moment and cant find info needed anywhere.
The following is easy:
a   db   254
---
mov al,a   
add al,3
jc M1             

M1:
adc ah,0           ;output in AX
---
hence 2 problems:
1.  a   word    65534
---
mov ax,a   
add ax,2
jc M1             

M1:
?               ;output in EAX?   
---
2.  a   dword    fffffffeh
---
mov eax,a   
add eax,2
jc M1             

M1:
?               ;output in ? And how can i take it to put it,say,in wsprintf()?   

Thanx a lot.

dedndave

well - this is 16-bit code - we have a special forum for that
"a" ? - try to use longer/more descriptive names for variables

to display a 32-bit value in decimal with 16-bit code, you need a multiple precision conversion routine
give me a little time to come up with one

it would be much easier to use 32-bit code - lol
in fact, we will make this a 32-bit project - i now see you have eax in your post

dedndave

i cheated by using the masm32 sstr$ macro to display the values - lol
is this for school ?


        INCLUDE \masm32\include\masm32rt.inc

        .DATA

Value1  dd 0FFFFFFFEh
Value2  dw 65534
Value3  db 254

        .CODE

_main   PROC

        mov     al,Value3
        add     al,3
        xor     edx,edx
        mov     dl,al
        print   sstr$(edx),13,10

        mov     ax,Value2
        add     ax,2
        xor     edx,edx
        mov     dx,ax
        print   sstr$(edx),13,10

        mov     eax,Value1
        add     eax,2
        print   sstr$(eax),13,10

        inkey
        exit

_main   ENDP

        END     _main