Question: Given the following code, in ASSEMBLY language (MASM x86) add code for multibyte subtraction of sum - decimal_two to get decimal_one DECIMAL OFFSET 5 ;
Given the following code, in ASSEMBLY language (MASM x86) add code for multibyte subtraction of "sum - decimal_two" to get decimal_one

DECIMAL OFFSET 5 ; offset from right of string data decimal_one BYTE "100123456789765" decimal_two BYTE "900402076502015" sum BYTE (SIZEOF decimal_one 1) DUP (0),0 ; 1001234567.89765 9004020765.02015 code main PROC ; Start at the last digit position mov esi,SIZEOF decimal one1 mov edi, SIZEOF decimal_one mov ecx, SIZEOF decimal_one mov bh, 0 set carry value to zero L1 : ah, 0 ; clear AH before addition mov mov al,decimal_oneesi]get the first digit add al,bh ; add the previous carry ; adjust the sum (AH-carry) ; save the carry in carryl ; convert it to ASCII ; add the second digit ; adjust the sum (AH = carry) ; OR the carry with carryl ; convert it to ASCII ; convert AL back to ASCII ;save it in the sum ; back up one digit mov bh, ah or bh, 30h add al,decimal_two [esi] bh, ah or or bh, 30h or mov sum [edi],al dec esi dec edi loop L1 mov sum [edi], bh al, 30h ; save last carry digit exit main ENDP END main DECIMAL OFFSET 5 ; offset from right of string data decimal_one BYTE "100123456789765" decimal_two BYTE "900402076502015" sum BYTE (SIZEOF decimal_one 1) DUP (0),0 ; 1001234567.89765 9004020765.02015 code main PROC ; Start at the last digit position mov esi,SIZEOF decimal one1 mov edi, SIZEOF decimal_one mov ecx, SIZEOF decimal_one mov bh, 0 set carry value to zero L1 : ah, 0 ; clear AH before addition mov mov al,decimal_oneesi]get the first digit add al,bh ; add the previous carry ; adjust the sum (AH-carry) ; save the carry in carryl ; convert it to ASCII ; add the second digit ; adjust the sum (AH = carry) ; OR the carry with carryl ; convert it to ASCII ; convert AL back to ASCII ;save it in the sum ; back up one digit mov bh, ah or bh, 30h add al,decimal_two [esi] bh, ah or or bh, 30h or mov sum [edi],al dec esi dec edi loop L1 mov sum [edi], bh al, 30h ; save last carry digit exit main ENDP END main
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
