
- •Workbook
- •Workbook Topics
- •Binary and Hexadecimal Integers
- •Answers: Binary and Hexadecimal Numbers
- •Signed Binary Representation
- •Signed Integers
- •Answers: Signed Integers
- •Tutorial: Floating-Point Binary
- •Floating-Point Binary Representation
- •Answers: Floating-Point Binary
- •Tutorial: The Precision Problem
- •Register and Immediate Operands
- •Register and Immediate Operands
- •Addition and Subtraction Instructions
- •Answers: Addition and Subtraction Instructions
- •Direct Memory Operands
- •Answers: Direct Memory Operands
- •Indirect and Indexed Operands
- •Answers: Indirect and Indexed Operands
- •Mapping Variables to Memory
- •http://www.nuvisionmiami.com/books/asm/workbook/memmap.gif
- •MS-DOS Function Calls - 1
- •http://www.nuvisionmiami.com/books/asm/workbook/dos1-1.asm
- •http://www.nuvisionmiami.com/books/asm/workbook/dos1-2.asm
- •http://www.nuvisionmiami.com/books/asm/workbook/dos1-3.asm
- •http://www.nuvisionmiami.com/books/asm/workbook/dos1-4.asm
- •http://www.nuvisionmiami.com/books/asm/workbook/dos1-5.asm
- •MS-DOS Function Calls - 2
- •http://www.nuvisionmiami.com/books/asm/workbook/dos2-1.asm
- •http://www.nuvisionmiami.com/books/asm/workbook/dos2-2.asm
- •http://www.nuvisionmiami.com/books/asm/workbook/dos2-3.asm
- •http://www.nuvisionmiami.com/books/asm/workbook/dos2-4.asm
- •Error-Correcting Codes
- •Boolean and Comparison Instructions
- •Answers: Boolean and Comparison Instructions
- •Decoding 12-Bit FAT
Answers: Addition and Subtraction Instructions
Answers: Addition and Subtraction
Instructions
1. Indicate whether or not each of the following instructions is valid.
a.add ax,bx |
V |
b.add dx,bl |
Ioperand size mismatch |
c.add ecx,dx |
I |
d.sub si,di |
V |
e.add bx,90000 |
Isource too large |
f.sub ds,1 |
Icannot use segment reg |
g. dec ip |
Icannot modify IP |
h. dec edx |
V |
i.add edx,1000hV
j.sub ah,126h Isource too large
k.sub al,256 Isource too large
l.inc ax,1 Iextraneous operand
2. What will be the value of the Carry flag after each of the following instruction sequences has executed?
(notate: CY = carry, NC = no carry)
a.mov ax,0FFFFh CY add ax,1
http://www.nuvisionmiami.com/books/asm/workbook/addsub_ans.htm (1 of 4) [1/15/2003 4:43:56 PM]
Answers: Addition and Subtraction Instructions
b.mov bh,2 sub bh,2
c.mov dx,0 dec dx
d.mov al,0DFh add al,32h
e.mov si,0B9F6h sub si,9874h
f.mov cx,695Fh sub cx,A218h
NC
?? (Carry not affected by INC and DEC)
CY
NC
CY
3. What will be the value of the Zero flag after each of the following instruction sequences has executed?
(notate: ZR = zero, NZ = not zero)
a.mov ax,0FFFFh ZR add ax,1
b.mov |
bh,2 |
ZR |
|
sub |
bh,2 |
||
|
|||
c.mov |
dx,0 |
NZ |
|
dec |
dx |
||
|
|||
d.mov |
al,0DFh |
NZ |
|
add |
al,32h |
||
|
e.mov si,0B9F6h NZ sub si,9874h
f.mov cx,695Fh |
ZR |
|
add cx,96A1h |
||
|
http://www.nuvisionmiami.com/books/asm/workbook/addsub_ans.htm (2 of 4) [1/15/2003 4:43:56 PM]
Answers: Addition and Subtraction Instructions
4. What will be the value of the Sign flag after each of the following instruction sequences has executed?
(notate: PL = positive, NG = negative)
a.mov ax,0FFFFh PL sub ax,1
b.mov |
bh,2 |
NG |
|
sub |
bh,3 |
||
|
|||
c.mov |
dx,0 |
NG |
|
dec |
dx |
||
|
|||
d.mov |
ax,7FFEh |
NG |
|
add |
ax,22h |
||
|
e.mov si,0B9F6h PL sub si,9874h
f.mov cx,8000h |
PL |
|
add cx,A69Fh |
||
|
5. What will be the values of the Carry, Sign, and Zero flags after the following instructions have executed?
(notate: CY/NC, PL/NG, ZR/NZ)
mov ax,620h
sub ah,0F6h CY,PL,NZ
6. What will be the values of the Carry, Sign, and Zero flags after the following instructions have executed?
(notate: CY/NC, PL/NG, ZR/NZ)
mov ax,720h
sub ax,0E6h NC,PL,NZ
http://www.nuvisionmiami.com/books/asm/workbook/addsub_ans.htm (3 of 4) [1/15/2003 4:43:56 PM]
Answers: Addition and Subtraction Instructions
7. What will be the values of the Carry, Sign, and Zero flags after the following instructions have executed?
(notate: CY/NC, PL/NG, ZR/NZ)
mov ax,0B6D4h
add al,0B3h CY,NG,NZ
8. What will be the values of the Overflow, Sign, and Zero flags after the following instructions have executed?
(notate: OV/NV, PL/NG, ZR/NZ)
mov |
bl,-127 |
NV,NG,NZ |
dec |
bl |
9. What will be the values of the Carry, Overflow, Sign, and Zero flags after the following instructions have executed?
(notate: CY/NC, OV/NV, PL/NG, ZR/NZ)
mov cx,-4097
add cx,1001h CY,NV,PL,ZR
10. What will be the values of the Carry, Overflow, Sign, and Zero flags after the following instructions have executed?
(notate: CY/NC, OV/NV, PL/NG, ZR/NZ)
mov ah,-56
add ah,-60 CY,NV,NG,NZ
http://www.nuvisionmiami.com/books/asm/workbook/addsub_ans.htm (4 of 4) [1/15/2003 4:43:56 PM]