0% found this document useful (0 votes)
24 views9 pages

Section Review 4.1 & 4.2 & 4.3

The document contains a review of assembly language instructions and operands, including types of operands, MOV instruction rules, and flag values after various operations. It provides examples of valid and invalid instructions, as well as exercises related to incrementing, subtracting, and moving data in registers. Additionally, it discusses the implications of flags such as Carry, Sign, and Overflow in different scenarios.

Uploaded by

18-QADEER AHMAD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views9 pages

Section Review 4.1 & 4.2 & 4.3

The document contains a review of assembly language instructions and operands, including types of operands, MOV instruction rules, and flag values after various operations. It provides examples of valid and invalid instructions, as well as exercises related to incrementing, subtracting, and moving data in registers. Additionally, it discusses the implications of flags such as Carry, Sign, and Overflow in different scenarios.

Uploaded by

18-QADEER AHMAD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

REVIEW SECTION 4.

1:
Question # 1:
What are the three basic types of operands?
 Register
 Immediate
 Memory
Question # 2:
The destination operand of a MOV instruction
cannot be a segment register.
False
Question # 3:
In a MOV instruction, the second operand is known
as the destination operand.
False
Q# 4:
The EIP register cannot be the destination operand
of a MOV instruction.
True
Q# 5:
In the operand notation used by Intel, what does
reg/mem32 indicate?
A 32-bit register or memory operand
Q# 6:
In the operand notation used by Intel, what does
imm16 indicate?
A 16-bit immediate (constant) operand

Q# 7:
For each of the following statements, state
whether or not the instruction is valid:
a. mov ax,var1
b. mov ax,var2
c. mov eax,var3
d. mov var2,var3
e. movzx ax,var2
f. movzx var2,al
g. mov ds,ax
h. mov ds,1000h
(a) not valid
(b) valid
(c) not valid
(d) not valid
(e) not valid
(f) not valid
(g) valid
(h) not valid
Q# 8:
What will be the hexadecimal value of the
destination operand after each of the following
instructions execute in sequence?
mov al,var1 ; a.
mov ah,[var1+3] ; b.
(a) FCh
(b) 01h

Q# 9:
What will be the value of the destination operand
after each of the following instructions
execute in sequence?
mov ax,var2 ; a.
mov ax,[var2+4] ; b.
mov ax,var3 ; c.
mov ax,[var3-2] ; d.
(a) 1000h
(b) 3000h
(c) FFF0h
(d) 4000h
Q# 10:
What will be the value of the destination operand
after each of the following instructions
execute in sequence?
mov edx,var4 ; a.
movzx edx,var2 ; b.
mov edx,[var4+4] ; c.
movsx edx,var1 ; d.
(a) 00000001h
(b) 00001000h
(c) 00000002h
(d) FFFFFFFCh
Review 4.2:
Q# 1:
Write an instruction that increments val2.
inc val2
Q# 2:
Write an instruction that subtracts val3 from EAX.
sub eax,val3
Q# 3:
Write instructions that subtract val4 from val2.
Code:
mov ax,val4
sub val2,ax
Q# 4:
If val2 is incremented by 1 using the ADD
instruction, what will be the values of the Carry
and Sign flags?
C= 0, SF=1.
Q# 5:
If val4 is incremented by 1 using the ADD
instruction, what will be the values of the Overflow
and Sign flags?
OF=1, SF=1.
Q# 6:
Where indicated, write down the values of the
Carry, Sign, Zero, and Overflow flags after each
instruction has executed:
mov ax,7FF0h
add al,10h ; a. CF = SF = ZF = OF =
add ah,1 ; b. CF = SF = ZF = OF =
add ax,2 ; c. CF = SF = ZF = OF =
Write down the following flag values:
(a) CF=1, SF=0, ZF=1, OF=0
(b) CF=0, SF=1, ZF=0, OF=1
(c) CF=0, SF=1, ZF=0, OF=0
Q# 7:
Implement the following expression in assembly
language: AX _ (_val2 _ BX) _ val4.
Code example:
mov ax,val2
neg ax
add ax,bx
sub ax,val4
Q# 8:
Is it possible to set the Overflow flag if you add a
positive integer to a negative integer?
No.
Q# 9:
Will the Overflow flag be set if you add a negative
integer to a negative integer and produce a
positive result?
Yes.
Q# 10:
Is it possible for the NEG instruction to set the
Overflow flag?
Yes (for example, mov al,−128 . . . followed by . . . neg al).
Q# 11:
Is it possible for both the Sign and Zero flags to be
set at the same time?
No.
Q# 12:
Write a sequence of two instructions that set both
the Carry and Overflow flags at the same time.
Setting the Carry and Overflow flags at the same time:
mov al,80h
add al,80h
Q# 13:
Write a sequence of instructions showing how the
Zero flag could be used to indicate unsigned
overflow after executing INC and DEC instructions.
Setting the Zero flag after INC and DEC to indicate unsigned
overflow:
mov al,0FFh
inc al
jz overflow_occurred
mov bl,1
dec bl
jz overflow_occurred

Q# 14:
In our discussion of the Carry flag we subtracted
unsigned 2 from 1 by negating the 2 and adding it
to 1. The Carry flag was the inversion of the carry
out of the MSB of the sum. Demonstrate
this process by subtracting 3 from 4 and show how
the Carry flag value is produced.
Subtracting 3 from 4 (unsigned). Carry out of MSB is inverted and
placed in the Carry flag

1
11111
00000100
+11111101
00000001
mov al,4
sub al,3 ; CF = 0
Review 4.3:
Q# 1:
The OFFSET operator always returns a 16-bit value.
False.
Q# 2:
The PTR operator returns the 32-bit address of a
variable.
False.
Q# 3:
The TYPE operator returns a value of 4 for
doubleword operands.
True
Q# 4:
The LENGTHOF operator returns the number of
bytes in an operand.
False.
Q# 5:
The SIZEOF operator returns the number of bytes
in an operand.
True
Q# 6:
Insert a directive in the given data that aligns
myBytes to an even-numbered address.
Data directive:
.data ALIGN 2
myBytes BYTE 10h, 20h, 30h, 40h
etc.
Q# 7:
What will be the value of EAX after each of the
following instructions execute?
mov eax,TYPE myBytes ; a.
mov eax,LENGTHOF myBytes ; b.
mov eax,SIZEOF myBytes ; c.
mov eax,TYPE myWords ; d.
mov eax,LENGTHOF myWords ; e.
mov eax,SIZEOF myWords ; f.
mov eax,SIZEOF myString ; g.
(a) 1
(b) 4
(c) 4
(d) 2
(e) 4
(f) 8
(g) 5
Q# 8:
Write a single instruction that moves the first two
bytes in myBytes to the DX register. The resulting
value will be 2010h.
mov dx, WORD PTR myBytes
Q# 9:
Write an instruction that moves the second byte in
myWords to the AL register.
mov al, BYTE PTR myWords1
Q# 10:
Write an instruction that moves all four bytes in
myBytes to the EAX register.
mov eax, DWORD PTR myBytes
Q# 11:
Insert a LABEL directive in the given data that
permits myWords to be moved directly to a 32-bit
register.
Data directive:
myWordsD LABEL DWORD
myWords WORD 3 DUP(?),2000h
.code
mov eax,myWordsD
Q# 12:
Insert a LABEL directive in the given data that
permits myBytes to be moved directly to a 16-bit
register.
Data directive:
myBytesW LABEL WORD
myBytes BYTE 10h,20h,30h,40h
.code
mov ax,myBytesW

You might also like