0% found this document useful (0 votes)
65 views

Sheet 3

1) The document appears to be lecture notes for an assembly language programming course. It provides 20 questions and problems for students to work through related to assembly language instructions, data movement, arithmetic operations, and basic programming exercises. 2) Questions cover topics like understanding the function of common instructions like MOV, LEA, PUSHF; differences between similar instructions; writing programs to move/copy data in memory; performing arithmetic operations; and basic sorting/multiplication algorithms. 3) Programming exercises involve tasks like filling a memory range with a value, copying an array, adding/summing arrays, calculating a factorial, doubling BCD numbers in memory, and sorting

Uploaded by

Mohamed Alfarash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

Sheet 3

1) The document appears to be lecture notes for an assembly language programming course. It provides 20 questions and problems for students to work through related to assembly language instructions, data movement, arithmetic operations, and basic programming exercises. 2) Questions cover topics like understanding the function of common instructions like MOV, LEA, PUSHF; differences between similar instructions; writing programs to move/copy data in memory; performing arithmetic operations; and basic sorting/multiplication algorithms. 3) Programming exercises involve tasks like filling a memory range with a value, copying an array, adding/summing arrays, calculating a factorial, doubling BCD numbers in memory, and sorting

Uploaded by

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

University of Alexandria

Faculty of Engineering
Division of Communications & Electronics

Subject Name: Microprocessors Lecturer: Dr.Nayera Sadek


Academic Year: 2016-2017 Assistants: Khaled Essam

Third Year – Semester 1

SHEET 3 Introduction to Assembly Programming

1) Describe the function of each of the following instructions:


a) MOV BX, 03FFH b) LEA AX, [DATA]
c) LDS DI, [LIST] d) LES BX, [LIST]
e) PUSHF f) IN AL,0EEH

2) What is the difference between the two following instructions:


a) MOV BX, [DATA] and LEA BX, [DATA]
b) IN AL, 10H and IN AL, DX
c) OUT 10H, AX and OUT DX, AX

3) Write a program that fills memory locations from 5000H to 5FFFH with value 77H.

4) Write a program that uses REP and MOVS to copy an array. Assume that the length of the
array is stored at memory location 0400H, the original array starts at 0340H and the
destination area starts at 360H. Run your program using:
[0400H] = 03H, [0340H] = 4FH, [0341H] = 55H, [0342H] = 54H.

5) Write a program for the 8086 microprocessor that moves a block of data located in
memory from address B0200 to address B02F9 to a new location starting at address
B0600.The contents of the Data segment register DS is to be B000.
6) a) Write a program that forms a lookup table originated at 380H of the squares of the
decimal digits from zero to 8d.
b) Use the formed table in (a) to square the digit in 400H and place the square in 401H.
Run your program using:
i) [400H] = 04H ii) [400H] = 07H

c) Write a program that uses the table in (a) to add the squares of 400H and 401H and put
the sum in 402H. Run the program using: [400H] = 03H and [401H] = 06H.

7) What is wrong with the following instructions?


a) ADD CL, AX.
b) INC [BX].
c) ADD [BX],12H

1
8) Find the result of IDIV BL if
a)AX=0010H and BL=FDH
b)AX=-16d and BL=3d

9) Write the instruction that performs the following operations:


a) AND BX with DX and save the result at BX.
b) AND the data stored 4 words before the location addressed by SI with DX and save
the result in DX.
c) OR 1122H with BP.
d) OR AH with memory location WHEN and save the result in WHEN.
e) XOR the data addressed by BX and DX and save the result in memory.
f) XOR the data stored 30 words after the location addressed by BP with DX and save
the result in DX.

10) Develop a short sequence of instructions that perform the following operations:
a) Add the contents of AL, BL, CL, DL and AH and save the result in DH.
b) Subtract the numbers in DI, SI and BP from the AX register and store the difference in
BX.
c) Cube the 8-bit number found in CL, assuming that CL contains a 5 initially.
d) Divide the number in BL by the number in CL and then multiply the result by 2.
e) Save the content of AL in BX as word.
f) Implement the following equation: 7(AL)-5(BL)-(DX)/8 and store the result in AX.
(Assume that DX is divisible by 8).
g) Set the rightmost 4 bits of AX, clear the 4 leftmost bits of AX and invert bit positions
7, 8 and 9 of AX.
h) Scan through a section of byte memory called for a 66H.

11) Two 32 bits numbers, one is stored at DS: 200 and the other at DS: 100.Write a program
to add these two numbers and stores the result at DS: 300

12) Write a program that add 2 hexadecimal digits stored in memory location DS: 100 as one
byte.

13) Write a program that adds an array of unsigned 8-bit numbers starting at 340H and puts
the sum in 400H. The length of the array is in 401H. Run the program with the following
data: [401] = 04H, [340H] =3EH, [341H] =47H, [342H] =F5H, [343H] =2AH.

14) Write a program that adds an array of unsigned 16-bit numbers starting at 340H and puts
the sum in 400H. The length of the array is in 401H. Run the program with the following
data: [401] = 02H, [340H]=36H, [341H]=21H, [342H]=97H, [343H]=18H.

15) Write a program to calculate factorial N (given N = 7).

16) Write a program that stores the BCD numbers in the memory starting at address 340H.
Then the program doubles each element and stores the results in the same memory
location.

17) Write the instruction that performs the following operations:


a) Shift DI right 1 place with a 0 moved into the leftmost bit position.

2
b) Move all the bits in AL left 1 place making sure a 0 moves into the rightmost bit
position.
c) Rotate the bits left 1 place in SI.
d) Rotate through carry DX 1 place to the right.
e) Move the DH register right 1 place with the sign bit shifted through DH.

18) If AX=6F55H, DS=3245H and CX=0100H, find the change in AX after the execution of
each of the following lines and the value of CX at the end of the program

a) MOV AX,1234H
b) MOV BX ,AX
c) NOT AX
d) AND AX,BX
e) OR AX ,BX
f) XOR CX,CX
g) MOV CL,02H
h) SHL AX,CL
i) SAR AX,CL
j) RCL AX,CL

19) Write an assembly program to sort 50 unsigned numbers stored in memory starting at
address 50C70H in an ascending order.

20) Without using MUL/IMUL instruction, write a sequence of instructions that multiply AX
with:
a) 4d b) 10d

You might also like