1 Sample - Answer

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Problem 2)

What will be the value in AX after executing the following instructions? Give the answer
in both hexadecimal and binary.
mov al,15 AX=??0F CL=??
mov ah,15 AX=0F0F CL=??
xor al,al AX=0F00 CL=??
mov cl,3 AX=0F00 CL=03
shr ax,cl AX=01E0 CL=03
add al,90h AX=0170 CL=03 CY=1
adc ah,0 AX=0270
___0270h______________
___0000 0010 0111 0000

Problem 3)
Suppose you had a different processor that was designed and operated similarly to the
8086/8088 architecture with the following differences: All of the registers are 8-bit
registers, and the physical address (PA) is a 10-bit number.
Question A (5 points) Given what you know about the 8086/8088 architecture, what
would be the size of the total addressing space on this new device?
____1KB or 1,024 Bytes___
Question B (5 points) Given what you know about 8086/8088 addressing, what would
be the size of the “offset window” at each segment location through which you could
address memory?
_____256 Bytes__________

Problem 4)
What will be the value in AX after executing the following instructions? Assume that DS
and ES are set up appropriately to access the variable ‘array’. Give the answer in
hexadecimal:
Byte Offset 1 0 3 2 5 4 7 6
array dw 1111h, 2222h, 3333h, 4444h
mov bx,1 BX = 0001
mov si,6 SI = 0006
mov ax,array[bx][si-2]
BX + SI – 2 = 5 ___44 33h______________
mov ax,array[bx][si] ; __55 44h______________

Problem 5)
Consider the following fragment of assembly code:
array dw 7,6,5,4
count dw 4
...
xor ax,ax
stc
mov cx,count
mov si,offset array
label1: adc ax,word ptr [si]
add si,2
loop label1
label2:

Question A:
The body of the loop will execute 4 times (CX = 4). On each pass through the
loop, AX will have the following values:
AX Array[SI] CF
AX = 0 + 7 + 1 = 8
AX = 8 + 6 + 0 = 14
AX = 14 + 5 + 0 = 19
AX = 19 + 4 + 0 = 23 = 17h
a) What will be the value in AX when control reaches label2?
____23 or 17h __________
Question B:
b) What is the purpose of the line:
xor ax,ax
_It zeroes the AX register._______

Question C:
c) Write an efficient and functionally equivalent code segment for the
line:
loop label1
DEC CX
CMP CX, 0
JNZ label1

Problem 6)
What will be the final value of AX in this example?
mov ax,0
mov cx,10 ; outer loop counter
L1:
mov ax,3
mov cx,5 ; inner loop counter
L2:
add ax,5
loop L2 ; repeat inner loop
loop L1 ; repeat outer loop
Problem 7)
Write a single intel instruction to replace each of the following.

a) DEC AX SUB AX, 1

b) LEA AX, DAT1 MOV AX, OFFSET DAT1

c) NOT AX XOR AX, FFFFH

d) BT AX, 5 TEST AX, 0020H

e) MOV AX, 8 OR 2 MOV AX, 10

Choice:
1.Covert 215D to binary ( )。
① 11101010B ②11101011B ③11010111B ④11010110B

2. Suppose to save 3963D in variable Y, then( )。

①(Y)=27H,(Y+1)=2FH ②(Y)=7BH,(Y+1)=0FH
② (Y)=39,(Y+1)=63 ④(Y)=63,(Y+1)=39

3. X1=+0111100B,X2=-0001110B,then 2’complement of [X1+X2] is( )。

①00111100B ②00101110B ③11110010B ④100101110B

4. in the following instruction, which one is invalid ( )


A.MOV AL,[1000H] B.CMP AL,[1000H]
C.CMP [1000],[BX] D.MOV [1000],BX

5. in the addressing mode of [BP+0AH],the default segment register is( )


①DS ②ES ③SS ④CS

6. In the following instructions, which one is valid ( 4)


①ADD AL,[BX+BP+6] ②CMP 36H,AL
AND 80H,[SI] ④INC [DI]

7. if(IP)=1000H,(SP)=2000H,(BX)=283FH, the machine code of instruction


CALL WORD PTR[BX] is FF17H. after this instruction be executed, (1FFEH)=
① 28H ②3FH ③00H ④02H

8. suppose:VAR DW 1,2,$+2,5,6
The offset of VAR is 0010H,(0014H)=( ).
① 2H ②4H ③6H ④16H
9. To reserve a 200 bytes for BUFFER, which instruction is correct? ( d )
a. BUFFER DW 200 DUP(?) b. BUFFER DB 200
c. BUFFER DD 200 DUP(?) d. BUFFER DB 200 DUP(?)

10.(DS)=2000H,the offset is 0120H,the physical address is(b )


A.02120H B.20120H C.21200H D.03200H

11.(CS)=3000H,(DS)=4000H,(ES)=2000H,(SS)=5000H,(AX)=2060H,
(BX)=3000H,(CX)=0005,(DX)=0,(SI)=2060H,(DI)=3000H,(43000H)=0A006H,
(23000H)=0B116H,(33000H)=0F802H,(25060H)=00B0H,(SP)=0FFFEH, (CF)=1,
What will be the value in registers after executing the following instructions?
1.SBB AX,BX; AX=___f05f____cf=1
2.XOR BX,0FFE7H; BX= CFE7______
3.SAR AX,CL; AX=_0103_______
4.JMP WORD PTR[BX]; IP=___0A006H _____
5.XCHG AX,ES:[BX+SI]; AX=___00B0_____

Programming:

1) Write a loop in assembly code that will execute 6 times: (5 points)


mov cx,06
L1: loop l1
2) Using the following table as a guide, write a program that asks the
user to enter an integer test score between 0 and 100. The program
should display the appropriate letter grade:

3) Write a program to find the maximum number in an array. The array


definition is as following, you should find the maxnum with a
subprocedure.
array db 23,14,3,8,17,20

You might also like