Sheet 3
Sheet 3
Faculty of Engineering
Division of Communications & Electronics
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.
1
8) Find the result of IDIV BL if
a)AX=0010H and BL=FDH
b)AX=-16d and BL=3d
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.
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.
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