Question#1 Write a short program demonstrating that the INC and DEC instructions
ID: 3597579 • Letter: Q
Question
Question#1
Write a short program demonstrating that the INC and DEC instructions do not affect the Carry flag.
Question#2
Write a program that uses addition and subtraction to set and clear the Overflow flag.
After each addition or subtraction, insert the call DumpRegs statement to display the registers and flags.
Make sure to include an ADD instruction that sets both the Carry and Overflow flags.
Using comments, explain how and why the Overflow flag was affected by each instruction.
Question#3
Write a program that uses addition and subtraction to set and clear the Carry flag.
After each instruction, insert the call DumpRegs statement to display the registers and flags.
Using comments, explain how and why the Carry flag was affected by each instruction.
Question#4
Insert the following variables into a program:
Uarray WORD 1000h, 2000h, 3000h, 4000h
Sarray SWORD -1, -2, -3, -4
Write instructions that use direct-offset addressing to move the four values in Uarray to the EAX, EBX, ECX, and EDX registers.
When you follow this with a call DumpRegs statement the following register values should display:
EAX=00001000 EBX=00002000 ECX=00003000 EDX=00004000
Then write instructions that use direct-offset addressing to move the four values in Sarray to the EAX, EBX, ECX, and EDX registers.
When you follow this with a call DumpRegs statement the following register values should display:
EAX=FFFFFFFF EBX=FFFFFFFE ECX=FFFFFFFD EDX=FFFFFFFC
Question#5
Write a program that implements the following arithmetic expression:
EAX = -val2 + 7 – val3 + val1
Use the following data definitions:
val1 SDWORD 8
val2 SDWORD -15
val3 SDWORD -20
In comments next to each instruction, write the hexadecimal value of EAX.
Insert a call DumpRegs statement at the end of the program.
Explanation / Answer
3)
The required program is: TITLE Subtract/Add Three (subtractThree.asm);
Description: This program subtracts 3 integers using only 16 bit registers.
INCLUDE Irvine32.inc
.code main PROC mov ax,8000h;
ax = 8000h mov bx,2000h;
bx = 2000h mov cx,3000h;
cx = 3000h sub ax,bx;
subtract bx from ax, ax = 6000h sub ax,cx ;
subtract cx from ax, ax = 3000h sub cx,bx ;
subtract bx from cx, cx = 1000h call DumpRegs ;
display registers exit ;
halt program main ENDP ;
end procedure END main ;
end program Results: EAX=00003000 EBX=7FFD2000 ECX=00121000 EDX=7C90E514 ESI=01CB4228 EDI=D8DB1C09 EBP=0012FFF0 ESP=0012FFC4 EIP=0040102A EFL=00000206 CF=0 SF=0 ZF=0 OF=0 AF=0 PF=1 Press any key to continue
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.