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

ID:2o2oB4ANGSup NAME: BttuvAN ueTA

A
Recheck Request:

38

BIRLAINSTITUTEOF TECHNOLOGY AND SCIENCE, PILANI


Second Semester 2022-23 Mid semester Exam
Mar 16, 2022 ECE/EEE/CS/INSTR F241 Microprocessor programming &Interfacing
MID_SEMESTER EXAMINATION 75 M,90 minutes

Q1. Answer the following questions for 80386


20
processqrs (except part a) [2Mx43BM
a. 8086 has address lines and data lines.
D. Write a single instruction to swap the bytes in the register AK(i.e. if
the register AX had content 3456h,after the
operation it should have 5634h) RoL Ax,
C. Assume AX= 9354H, what will be the value of
AX after the operation SAR AX, 4. AX = FA3SA(in hex)
d. What will be the value of DX after following
instructions are executed. Assume AX= 9040H, BX= 8030H, DX=1037H.
ADD AX, BX
RCRDX, 4 DX=
H (in hex)
Q2. Write the machine code in hex for the following
instruction for the 80386 processor working in 32-bit mode of
operation. (4M+ 2M= 6M)
MOV (ECX+8*EDX], EBX Machine code (in hex) 896co1 H
b. MOV BX, (ECX+24H] Machine code (in hex) k6 gRS24 H
Q3. What should be the flag values after the following
instructions are executed AX= 4100H, BX= 42A8H, CX= 320OH.
Assume that the following two instructions are independent and the
starting point for both the instructions [2Mx2= 4M)
above-mentjoned register values are the
ADD AX, BX PF = ,OF=
b. ADD CX, AX PF= ,OF=

Q4. Assume the following register values: SI= 3000H, BX=4000H,


DI=5000H, CS=240OH, DS= 4000H, SS=8300H.
Assume that memory content at 43000H is 88H and that at 43001H is 89H. What will be
the content of the CS and IP
registers after the execution of the following instructions. In case the instruction is invalid put the
value of CS and IP
as xx. Also consider the memory fields and content as given below[2Mx2= 4M]

MEMORY CONTENT MEMORY CONTENT


8949E H 22H 4449E H 35H
8949F H 23H 4449F H 81H
89500 H 99H 44500h H 86H
89501 H 83H 44501h H 21H

24g0h
i. JP WORD PTR [SI] ;PF=1 before this instruction IP=8889h
CALL WORD PTR [BPI[SIJ[O100HJ CS= 240oh , IP= 349 h

-l
QS. Consider the following code snippet and specifywhich mode of memoryorganlzatlon is used in an x86,(machine
Note that due to some restriction only 64KB is allowed for data segment. (4M) Ans.
D4TA
EXAMI DD 2000}H, 3000H. 330011, 430017
CODE
MOT DI, 30
MOT B, 10
CALL EAMI
Q6. Give the name of the addressing mode for the following instructlons (1Mx6= 6M]
a.
MOV AL, BH
b. MOVCL, (EBX+ 4* EAX] Registy addressing
NOT WORD PTR [BX][O104H]
Sealdadyaoking
d. MOV EBX, (ESl+0234H] legistr teakue addresy
INC LOC1
Ragishox elaku addesig
Ragi shr Dixect
*Note: LOC1 is is the label of a byte sized odllg
f.
location
LEA BX, LOC2
Tronediah addnesting
*Note: LOC2 is the labelof an instruction at
CS:033Oh

Q7. Consider the following sequential set of


instructions. |DATI 001048 0020 00DATA 0080
After each instruction, mention what will be the value of 00107 002100
10091
0012 64 0022 0022 x
the registers that are asked against it in 0018 41,
hexadecimal. WRD
D024 0030

[IMx5= 5M)(for memory location/ labels offset, refer to the 0014


0016 00
10 0024 0084
0026
figure given on the right side) 0016 00 0026
00176 0027
0018 10 0018
MOV SL, DAT3 SI= 0019 109 0020
MOV AL, DATI+1 AL= 67 DATS 001A 02 002A 003A X
MOV BX, DATI+4 BX= 001300 002B 008B
0010 00 0020 DWBD 009Co4
ADD BX, 0020H BX= O30 O01D00 002D
DAT8 001E 0
MOV AL, (BX] AL= 009E 0032 02
00100 002P

Q8. Consider the code given on the right side


.model tiny
.data
Write the contents in the following memory locations In hex. .org 028Oh
If any location cannot be determined, put it as xx. (1.5x4= 6M] dat1 equ 15
dat2 dw 23h, 24h, 25h
0280H 23h dat3 db 0Ah
align 4
0289H 2Gh datdd 2530h, 3233h,
0290H 5544h
align 2
0294H dat4 dw 45h
Q9. What will be the value of the registers after the following
operations [SM]
MOV BX, OF320H
MOV AX, OF3FOH AX= Fslo DX= 97D?
IMUL BX
1020 3040H,
Q10. Assume SS= 3000H, SP= 0050H, DS= 2000H, EBX= What will be the content of the following
0100H. Assume 00H to be present in all
EDX = $145 6070H, Sl = memory locations after the execution of
40050H before the following
memory locations from 2005OH to the set of instructions on the left?
instructions are executed. [1.5x4= 6M)
PUSH EBN'
3004DH
POP CX
3004BH Goh
PUSH EDX
PUSH WORD PTR (SI] 30047H 2oh
PUSH CX 30046H

Q11. Consider the following instructions.Note that the opcode for JMP instruction is EB. Fillinthe blank with the
right machine code (in hex) which willcome in the two blanks. (Assume any suitable data if required) [3Mx2 =6M)
Instruction Machine code (in hex)
MOV AX, 4000H B8 00 40
MOV DS. AX SE D8
MOV CX, 0032H B9 32 00
MOVSI, 0000H BE 00 10
JMP X2 EB o3X% Fillin the blank
XI: ADDBL. [SI] 02 1C
INC BH FE C7
INC SI 46
X2: DEG CX 49
JMP XI ERFB Fill in the blank
Q12. Write the register values in hex after the execution of following code [2M]
.MODEL TINY
.DATA
.ORG 1030H
DAT IDB 50H 20H 30H 25H 80H 40H 35H 5SH 6SH 75H
.CODE
.STARTUP
MOV D1, OFFSET DATI
MOV AL. 80H
MOV CX, 10H
CLD
REPNE SCASB
.EXIT
END DI= lo35
Q13. Write the register values in hex after the execution of following code [3M]
.MODEL TINY
.DATA
.ORG 1030H
DAT IDB 50H 20OH 30H 2SH 80H 40H 3SH 2SH 70H 7SH
.CODE
.STARTUP
MOV SI, OFFSET DATI
MOVDI, OFFSET DATI
ADD DI,7
STD
CMPSW
JA X1
X2: MOV CX, 4534H
JMP OVER
X1: MOV CX, 7556H
OVER:
.EXIT
END Dl: H,SI: H, CX = H
Q14 You have to write a macro named NINE Which performe the foliowing operation OutPar-9*InPar where
InPar and OutPar are the parameters to the macro NINE Yoy are not allowed to use MUL/IMUL in this macro
The only register youcan uSe inside macro is CX, and are allowed to use only one ADD instruction. Assume that
the range of InPar is from 50H - 200H The mocro should not have more than 6 lines of code (including the
mocro heoder ond footer).
Furthermore, write a complete 8086 ALP which will change the contents of DX register with 27 times the content
of BX (i e. DX=27*BX). This ALP is allowed to call the macro NINE only one time. Only BX, DX and CX can be used
in this program. The code between. stortup and. Exit (exclvding the entire macro) should not exceed 4 lines
You can use the ADD instructiononly once in the ALP. No other arithmetic instruction can be Used. (10M]

8086 ALP Macro

NINE MACRO TAtlar

SA
Moy

ENDM

NiNe MACKO Thlor, Qutloy

Cx, 0o0
SAL TnPar,Ck
Mov C, Tn Par
Mov Outlar,
ENDM

You might also like