Professional Documents
Culture Documents
Sheet Ch:10
Sheet Ch:10
Sheet Ch:10
1) Assume the real mode. If (DS) = 1000H, (SS) = 2000H, (CS) = 3000H,
(BP) = 000FH, and (BX) = 000AH before execution of the following
Pentium instructions:
(a) MOV CX,[BX] 20-bit physical address=0000A H+10000 H=1000A H
Find the 20-bit physical address after execution of each of the instructions above.
2) If (DS) = 205FH and OFFSET = 0052H, what is the 20-bit physical address
in real mode?
20-bit physical address=205F0H+00052H=20642H
Start segment1=0100+0000=0100 H
End segment1=0100+FFFF=100FF H
Start segment2=0200+0000=0200 H
End segment2=0200+FFFF=101FF H
5) XXXX
6) Determine the effect after execution of instructions:
(a) MOVZX EAX,CH
Each of the following Pentium Prior to execution of this MOVZX
instruction, assume
(EAX) = 80001234H
(ECX) = 00008080H
So CH=80H EAX=00000080H
(b) MOVSX EDX,BL
Prior to execution of this MOVSX assume
(EDX) = FFFFFFFFH
(EBX) = 05218888H
So BL=88H EDX=FFFFFF88H
7) Find the overflow, direction, interrupt, trap, sign, zero, parity, and carry flags
after execution of the following Pentium instruction sequence:
MOV AH, OF H AH=0F H
SAHF STORE AH IN FLAGES
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 NT OF DF IF TF SF ZF 0 AF 0 PF 1 CF
0 0 0 0 1 1 1 1
0 F
12) Write the Pentium instruction sequence to clear the trap flag in the
FLAGS register without affecting the other flags.
14) Write a Pentium assembly language program that will convert a BCD
number in AL to a seven-segment code using a look-up table containing the
seven-segment codes of the BCD numbers. Use a common-cathode display.
Assume that the table is stored in memory starting at offset 2000H. Use the
XLAT instruction. Initialize DS to 3000H
.486
.data
Org 2000h
db 3fh
db 06h
.
.
.code
Push ax
Mov ax,3000h
Mov ds, ax
Mov bx, 2000h
Pop ax
xlat
15) Write a Pentium assembly program to add a 64-bit number in ECX:
EDX with another 64-bit number in EAX: EBX. Store the result in EAX:
EDX.
Add edx,ebx
Adc eax,ecx
Mov bx,6080h
sub al,byte ptr[bx] ; sub the first bytes
pushf
Inc bx
popf
sbb ah,byte ptr[bx] ; sub the second bytes with borrow
Pushf ;store the sub operation effect on flags
Mov cx,ax ;store result of 2 bytes
Shr eax,16 ;the third byte now in al
Inc bx
Popf
sbb al,byte ptr[bx] ; sub the third bytes with borrow
Pushf ;store the sub operation effect on flags
Shl eax,16 ;mov the third byte in result back
Mov ax,cx ; store result of 2 bytes back
Popf ;restore flag
20) If (EBX) = 0123A212H and (EDX) = 46B12310H, then what are the
contents of EBX and EDX after execution of the Pentium instruction
XADD EBX,EDX?
21) If (BX) = 271AH, (AX) = 712EH, and (CX) = 1234H, what are the
contents of AX after execution of the Pentium instruction
CMPXCHG CX.BX?
[AX]!=[CX]
So AX=CX=1234H
BX=271AH as it is.
CX=1234H as it is.
22) Write a Pentium assembly language program to perform (X2 + Y2)
where X is a signed 8-bit number stored in CL and Y is an unsigned 16-bit
number stored in low 16 bits of SI. Save the 32-bit result onto the stack.
Assume SP is already initialized.
Mov al,cl
Imul cl ;now ax=cl*cl
push ax ; store result of cl*cl in stack
Mov ax,si
mul si ; now dx:ax=si*si
Mov bx,ax
Mov cx,dx ; store result of si*si in cx:bx
Pop ax ;restore result of cl*cl from stack
Cwd ;extend the ax >>dx:ax
Add ax,bx
Adc dx,cx
Push ax
26) Write a Pentium assembly program to multiply the top two 16-bit
unsigned words of the stack. Store the 32-bit result onto the stack. Initialize
SS to 5000H and SP to 0020H
Mov ax,5000
Mov ss,ax ; Initialize ss
Mov sp,0020 ; Initialize sp
Pop ax
Pop cx
Mul cx
Push ax
Push dx
Mov al,ch
Cbw
Idiv cl
Mov ch,al
Mov cl,ah