Question: TITLE ArithmeticsOn 1 4 Bytes ; This program adds and subtracts 1 4 - byte ( 1 1 2 - bit ) integers. ; Name:

TITLE ArithmeticsOn14Bytes
; This program adds and subtracts 14-byte (112-bit) integers.
; Name: Dhruv Patel
; CPEN 3710
; Date: 10/2/24
INCLUDE Irvine32.inc
.data
bigVal1 BYTE 29h,2Dh,6Dh,3Dh,56h,9Dh,0BAh, 33h,3Ch,0B7h,07h,32h,07h,9Ch
bigVal2 BYTE 0A2h,0FFh,54h,0AEh, 55h,0A7h,0ECh, 0CAh, 0C1h,3Ah,0C4h,74h,0Eh,3Dh
bigVal3 BYTE 31h,95h,7Ah,0FAh, 0EFh, 23h,4Dh,84h,0E3h,0ACh, 3Eh,0B5h,0E4h,0C1h
bigVal4 BYTE 0ECh, 47h,13h,17h,0BDh,0AFh, 2Ah,6Fh,0C5h,7Dh,0C5h,03h,0A0h,5Ah
result1 BYTE 14 DUP(?)
result2 BYTE 14 DUP(?)
.code
main PROC
; First operation: Addition of bigVal1 and bigVal2
mov esi, OFFSET bigVal1 ; Pass first operand (bigVal1)
mov edi, OFFSET bigVal2 ; Pass second operand (bigVal2)
mov ebx, OFFSET result1 ; Store result in result1
mov ecx, 0 ; Set operation to addition (0 means addition)
call subOperation ; Call the subprogram for addition
; Display result1(Addition)
mov esi, OFFSET result1
mov ecx, 14
call DumpMem
call DumpRegs
; Second operation: Subtraction of bigVal3 and bigVal4
mov esi, OFFSET bigVal3 ; Pass first operand (bigVal3)
mov edi, OFFSET bigVal4 ; Pass second operand (bigVal4)
mov ebx, OFFSET result2 ; Store result in result2
mov ecx, 1 ; Set operation to subtraction (1 means subtraction)
call subOperation ; Call the subprogram for subtraction
; Display result2(Subtraction)
mov esi, OFFSET result2
mov ecx, 14
call DumpMem
call DumpRegs
exit
main ENDP
subOperation PROC
pushad ; Save all general-purpose registers
mov edx, 0 ; Clear carry/borrow flag
mov ecx, 14 ; Set counter for 14 bytes
performLoop:
mov al,[esi] ; Load byte from first operand (bigVal1 or bigVal3)
mov bl,[edi] ; Load byte from second operand (bigVal2 or bigVal4)
test ecx, ecx ; Check if it's addition or subtraction
jne subtractionCheck
additionCheck:
add al, bl ; Add the two bytes
adc dl,0 ; Add with carry
jmp storeResult
subtractionCheck:
sub al, bl ; Subtract the two bytes
sbb dl,0 ; 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 14 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!
TITLE ArithmeticsOn 1 4 Bytes ; This program adds

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!