Docsity

Coding Assembly Language-Microprocessors-Lab Assignments, Exercises of Microprocessors

Toggle sidebar
bg1
Page 1 of 2
Lab Session 5 March 29
Note: every number is in hexadecimal. Define code at 1000:100
Bit0 is the first bit in a byte / word
Part A
Write the code to implement a search of number 07 in the memory 2000:300 (10 bytes)
02 30 50 01 07 50 60 70 0A 07
Using loope and then using loopne
1. observe the contents of CX and Zero flag before the execution of loopne
instruction. Write down the contents. Now trace the code and check when the
loop terminates write the contents of CX now.
2. now use loope instruction and proceed the same as you did in 1. what is the
difference you feel in both commands. Observe the contents of zero flag and CX
3. now update the memory 2000:300 (10 bytes) as
02 30 50 01 05 50 60 70 0A 80
and search the number 07 again use loopne instruction. Now check when the loop
terminates. And write the contents of CX and zero flag
Part B Write a subroutine which copies the positive number to the location 3000:700 and
the negative number to the location 3000:800 from a memory location 2000:500 (10
words)
2000:500 30F0 FF02 2080 AE03 20D0 1E03 20A1 207E 50B3 0293
1. what are the contents of status register before and after the execution of compare
instruction when a positive number is found
2. Trace the code and show the contents to the lab instructor.
Part C
1. Enter the following code
MOV AX,2000
MOV SS,AX
MOV SP,0010
MOV AX,10
MOV BX,20
CALL 0200
NOPNOP
2. Enter the following code in the memory location 1000:0200
ADD AX,BX
RET
MOV CX,2
3. before execution of the code observe the contents of SP and memory locations
SP-1, SP-2 and write down. Now trace the code in 1. Immediately after the
execution of CALL 200, check the contents SP and the memory location SS:SP
and SS:SP+1 and write down. Did the contents of stack modify after the
execution of CALL 0200. What do these contents represent? Also check the
contents of IP and write down. What is the next instruction to be executed and
what is its off-set address?
4. What is the next instruction to be executed immediately after the execution of
RET instruction?
5. What do the second and third bytes of the machine code of CALL 0200 represent.
What did u observe?
6. Is it different from NEAR jump instruction?
Part D (NEAR CALL)
1. Enter the following code in the memory location 1000:0100:
docsity.com
pf2

Partial preview of the text

Download Coding Assembly Language-Microprocessors-Lab Assignments and more Exercises Microprocessors in PDF only on Docsity!

Page 1 of 2

Lab Session 5 March 29

Note: every number is in hexadecimal. Define code at 1000: Bit0 is the first bit in a byte / word Part A Write the code to implement a search of number 07 in the memory 2000:300 (10 bytes) 02 30 50 01 07 50 60 70 0A 07 Using loope and then using loopne

  1. observe the contents of CX and Zero flag before the execution of loopne instruction. Write down the contents. Now trace the code and check when the loop terminates write the contents of CX now.
  2. now use loope instruction and proceed the same as you did in 1. what is the difference you feel in both commands. Observe the contents of zero flag and CX
  3. now update the memory 2000:300 (10 bytes) as 02 30 50 01 05 50 60 70 0A 80 and search the number 07 again use loopne instruction. Now check when the loop terminates. And write the contents of CX and zero flag Part B Write a subroutine which copies the positive number to the location 3000:700 and the negative number to the location 3000:800 from a memory location 2000:500 ( words) 2000:500 30F0 FF02 2080 AE03 20D0 1E03 20A1 207E 50B3 0293
  4. what are the contents of status register before and after the execution of compare instruction when a positive number is found
  5. Trace the code and show the contents to the lab instructor. Part C
  6. Enter the following code MOV AX, MOV SS,AX MOV SP, MOV AX, MOV BX, CALL 0200 NOPNOP
  7. Enter the following code in the memory location 1000: ADD AX,BX RET MOV CX,
  8. before execution of the code observe the contents of SP and memory locations SP-1, SP-2 and write down. Now trace the code in 1. Immediately after the execution of CALL 200, check the contents SP and the memory location SS:SP and SS:SP+1 and write down. Did the contents of stack modify after the execution of CALL 0200. What do these contents represent? Also check the contents of IP and write down. What is the next instruction to be executed and what is its off-set address?
  9. What is the next instruction to be executed immediately after the execution of RET instruction?
  10. What do the second and third bytes of the machine code of CALL 0200 represent. What did u observe?
  11. Is it different from NEAR jump instruction?

Part D (NEAR CALL)

  1. Enter the following code in the memory location 1000:0100:

docsity.com

Page 2 of 2

MOV AX,

MOV SS,AX

MOV SP,

MOV AX,

MOV BX,

CALL 0020

CALL 0220

NOPNOP

2. CS:

ADD AX,BX

RET

3. CS:

INC CX

INC DX

RET

  1. Before execution observe the contents of SP and memory locations SP-1, and SP- 2 and write down. Now trace the code in 1. Immediately after the execution of first CALL, check the contents SP and the memory location SP and SP+1 and write down. Did the contents of stack modify after the execution of CALL 0020. What do these contents represent? Also check the contents of IP and write down. What is the next instruction to be executed and what is its off-set address?
  2. What is the next instruction to be executed immediately after the execution of RET instruction in 2?
  3. What do the second and third bytes of the machine code of CALL 0020 and CALL 220 represent. How do you relate them with the memory location 1000:0020 and 1000:0220? Part E (FAR CALL)
  4. Enter the following code in the memory location 1000:0100: MOV AX, MOV SS,AX MOV SP, MOV AX, MOV BX, CALL 3000: NOP
  5. Enter the following code in the memory location 3000: MOV AX, INC CX ADD AX,CX RET
  6. Before execution of the code observe the contents of SP and memory locations SP-1, SP-2 SP-3 and SP-4 and write down. Now trace the code in 1. Immediately after the execution of CALL, check the contents SP and the memory location SP and SP+1, SP+2, SP+3 and write down. Did the contents of stack modify after the execution of CALL instruction was executed? What do these contents represent? Also check the contents of IP and CS and write down. What is the next instruction to be executed and what is its logical address?
  7. What is the next instruction to be executed immediately after the execution of RET instruction?
  8. What do the second, third, fourth and fifth bytes of the machine code of CALL represent?
  9. Is it different from FAR JUMP instruction

docsity.com