[Solved] Assembly program of adding two number [closed]


Those two lines are checking for a “negative” sign on either of the 16 bit zoned or unpacked decimal numbers, which contain one decimal digit per byte (bcd – binary coded decimal) in the low order bits (bits 0 to 3). The sign is stored in bits 4 through 7 of the least significant byte. Looking at the last byte of zoned or unpacked decimal number, a value of 0x10, 0x50, 0x90, 0xd0 would indicate a negative number.

The code after jne GLB.4 is doing an unpacked bcd add, but then it does a byte swap, so I’m not sure what it’s doing with the sum.

Can you include the Cobol data division for the two numbers, and the procedure division for the add?

;       using desktop calculator in hex mode
;               ecx = 002030405h      ;decimal 2345
;               eax = 002070809h      ;decimal 2789
        add     ecx,eax               ;ecx = 0040A0C0Eh
        add     ecx,0F6F6F6F6h        ;ecx = 0FB010304h  ;F6 does carries
        mov     eax,ecx               ;eax = 0FB010304h
        and     eax,060606060h        ;eax = 060000000h  ;eax = value to subtract
        shr     eax,004               ;eax = 006000000h  ; for the non carries
        and     ecx,00F0F0F0Fh        ;ecx = 00B010304h  ;clear any 'F's
        sub     ecx,eax               ;ecx = 005010304h  ;fix the non carries
                                      ;ecx = decimal 5134

6

solved Assembly program of adding two number [closed]