Question: Using the AddSub program from Section 3.2 as a reference, write a program that subtracts three integers using only 16- bit registers. Insert a call
Using the AddSub program from Section 3.2 as a reference, write a program that subtracts three integers using only 16- bit registers. Insert a call DumpRegs statement to display the register values.
;TITLE Add and Subtract (AddSub.asm) ; This program adds and subtracts 32-bit integers. INCLUDE Irvine32.inc
.code main PROC
mov eax,10000h add eax,40000h sub eax,20000h call DumpRegs exit
main ENDP
END main
let use the following values var1 400 var2 100 var3 70 var4 9
and then move var1 in to EAX and then subtract var2, then var3, and then var4 EAX should then hold 221

TITLE Add and Subtract, Version 2 ; This program adds and subtracts 32-bit unsigned ; integers and stores the sum in a variable. INCLUDE Irvine32.inc (AddSub2.asm) data vall DWORD 10000h val2 DWORD 40000h val3 DWORD 20000h finalVal DWORD? .code main PROC mov eax , val! add eax,va12 sub eax,val3 mov finalVal.eax call DumpRegs. exit ; start with 10000h : add 40000h ; subtract 20000h ; store the result (30000h) : display the registers ; predefined MS-Win function main ENDP END main TITLE Add and Subtract, Version 2 ; This program adds and subtracts 32-bit unsigned ; integers and stores the sum in a variable. INCLUDE Irvine32.inc (AddSub2.asm) data vall DWORD 10000h val2 DWORD 40000h val3 DWORD 20000h finalVal DWORD? .code main PROC mov eax , val! add eax,va12 sub eax,val3 mov finalVal.eax call DumpRegs. exit ; start with 10000h : add 40000h ; subtract 20000h ; store the result (30000h) : display the registers ; predefined MS-Win function 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
