Question: TITLE ArithmeticsOn 1 4 Bytes ; This program adds and subtracts 1 4 - byte ( 1 1 2 - bit ) integers. ; Name:
TITLE ArithmeticsOnBytes
; This program adds and subtracts byte bit integers.
; Name: Dhruv Patel
; CPEN
; Date:
INCLUDE Irvineinc
data
bigVal BYTE hDhDhDhhDhBAh, hChBhhhhCh
bigVal BYTE AhFFhhAEh, hAhECh, CAh, ChAhChhEhDh
bigVal BYTE hhAhFAh, EFh, hDhhEhACh, EhBhEhCh
bigVal BYTE ECh, hhhBDhAFh, AhFhChDhChhAhAh
result BYTE DUP
result BYTE DUP
code
main PROC
; First operation: Addition of bigVal and bigVal
mov esi, OFFSET bigVal ; Pass first operand bigVal
mov edi, OFFSET bigVal ; Pass second operand bigVal
mov ebx, OFFSET result ; Store result in result
mov ecx, ; Set operation to addition means addition
call subOperation ; Call the subprogram for addition
; Display resultAddition
mov esi, OFFSET result
mov ecx,
call DumpMem
call DumpRegs
; Second operation: Subtraction of bigVal and bigVal
mov esi, OFFSET bigVal ; Pass first operand bigVal
mov edi, OFFSET bigVal ; Pass second operand bigVal
mov ebx, OFFSET result ; Store result in result
mov ecx, ; Set operation to subtraction means subtraction
call subOperation ; Call the subprogram for subtraction
; Display resultSubtraction
mov esi, OFFSET result
mov ecx,
call DumpMem
call DumpRegs
exit
main ENDP
subOperation PROC
pushad ; Save all generalpurpose registers
mov edx, ; Clear carryborrow flag
mov ecx, ; Set counter for bytes
performLoop:
mov alesi ; Load byte from first operand bigVal or bigVal
mov bledi ; Load byte from second operand bigVal or bigVal
test ecx, ecx ; Check if it's addition or subtraction
jne subtractionCheck
additionCheck:
add al bl ; Add the two bytes
adc dl ; Add with carry
jmp storeResult
subtractionCheck:
sub al bl ; Subtract the two bytes
sbb dl ; Subtract with borrow
jmp storeResult
storeResult:
mov ebx al ; Store the result in result array
inc esi ; Move to the next byte of the first operand
inc edi ; Move to the next byte of the second operand
inc ebx ; Move to the next byte of the result
loop performLoop ; Repeat for all bytes
popad ; Restore registers
ret
subOperation ENDP
END main
No correct output shown... can you change the code according but based on the registers used!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
