8086-8051 Lab
8086-8051 Lab
Find the number of Positive and Negative numbers in a series of 10 bytes stored from memory location 3000:0200H.
Store the results in BL (positive) and BH (negative).
MOV AX, 3000H
MOV DS, AX
MOV SI, 200H
MOV CX, 10D/0AH
MOV BX, 0000H
RPT: MOV AL, [SI]
ROL AL, 1
JC NEG
INC BL
JMP SKIP
NEG: INC BH
SKIP: INC SI
LOOP RPT
STOP: JMP STOP
Add two 32bit data already stored in memory at 2000:100H and 2000:104H. What is the length of the result? Store
the result in memory at 2000:108H.
MOV AX, 2000H
MOV DS, AX
MOV SI, 100H
MOV CX, 02H
MOV DL, 02H ;STORES THE LENGTH IN BYTES
CLC
RPT: MOV AX, [SI]
MOV BX, [SI]04H
ADC AX, BX
MOV [SI]08H, AX
INC SI
INC SI
LOOP RPT
JNC SKIP
MOV AL, 00H
ADC AL, 00H
MOV [112H], AL
INC DL
SKIP: JMP SKIP
Transfer a block of ten data starting from DS: 0200H (source block) to ES: 0100H (destination block).
MOV AX, 2000H
MOV DS, AX
MOV AX, 3000H
MOV ES, AX
MOV SI, 200H
MOV DI, 100H
MOV CX, 0AH
CLD
REP MOVSB
Add twenty 8-bit numbers stored in data segment memory. Justify the length of the result and store in memory
MOV AX, 1000H
MOV DS, AX
MOV SI, 100H
MOV BL, 01H ;LENGTH IN BYTES
MOV AX, 0000H
MOV CX, 20D
RPT: ADD AL, [SI]
JNC SKIP
INC AH
SKIP: INC SI
LOOP RPT
MOV [SI], AX
CMP AH, 00H
JNZ STOP
INC BL
STOP: JMP STOP
Find out the largest number from a list of ten data bytes stored in memory location 3000:200H and store the result in
3000: 300H.
MOV AX, 3000H
MOV DS, AX
MOV SI, 200H
MOV CX, 09H
MOV AL, [SI]
INC SI
RPT: MOV BL, [SI]
CMP AL, BL
JNC SKIP
XCHG AL, BL
SKIP: INC SI
LOOP RPT
MOV [300H], AL
STOP: JMP STOP
Multiply two 16-bit unsigned numbers stored in memory. Store the result also in memory. (Record at least five set of
data for verification).
MOV AX, 1000H
MOV DS, AX
MOV SI, 100H
MOV DI, 200H
MOV AX, [SI]
MOV BX, [SI]02H
MUL BX
MOV [DI], AX
MOV [DI]02H, DX
Find number of "FF” in an array of 16 bytes stored from memory 2000:100H. Store the result in AL.
MOV AX, 2000H
MOV DS, AX
MOV SI, 100H
MOV CX, 16D
MOV AL, 00H
RPT: MOV BL, [SI]
CMP BL, FFH
JNZ SKIP
INC AL
SKIP: INC SI
LOOP RPT
STOP: JMP STOP
Find the number of even data in a series of 10 bytes stored from memory location 3000:0200H. Store the results in
BL.
MOV AX, 3000H
MOV DS, AX
MOV SI, 200H
MOV CX, 10D/0AH
MOV BL, 00H
RPT: MOV AL, [SI]
ROR AL, 1
JC SKIP
INC BL
SKIP: INC SI
LOOP RPT
STOP: JMP STOP
Write a program to find the square of the content of memory location 3000:0200H and place the result in
3000:0201H using look-up table method.
MOV AX, 3000H
MOV DS, AX
MOV SI, 200H
MOV BX, 100H ;LET THE LOOKUP TABLE IS STORED IN 3000:100H
MOV AL, [SI]
XLAT
MOV [SI]01H, AL
Divide a 16-bit unsigned number by another 16-bit unsigned number stored in memory. Store the quotient and
remainder also in memory. (Record at five set of data for verification).
MOV AX, 2000H
MOV DS, AX
MOV SI, 100H
MOV DI, 200H
MOV AX, [SI]
MOV DX, 0000H
MOV CX, [SI]02H
DIV CX
MOV [DI], AX ;QUOTIENT
MOV [DI]02H, DX ;REMAINDER
Transfer a block of 16 bytes from one place to another in memory in reverse order.
MOV AX, 2000H
MOV DS, AX
MOV AX, 3000H
MOV ES, AX
MOV SI, 210H
MOV DI, 110H
MOV CX, 10H/16D
STD
REP MOVSB
Divide a 16-bit signed number by another 16-bit signed number to obtain the quotient and the remainder. Refer
suitable memory for different data.
MOV AX, 2000H
MOV DS, AX
MOV SI, 100H
MOV DI, 200H
MOV AX, [SI]
CWD
MOV CX, [SI]02H
IDIV CX
MOV [DI], AX ;QUOTIENT
MOV [DI]02H, DX ;REMAINDER
A set of sixteen 8-bit data are stored in 16 consecutive memory locations in data segment. Write a program to find
the largest and the smallest numbers in BH and BL respectively.
MOV AX, 2000H
MOV DS, AX
MOV SI, 100H
MOV CX, 10H/16D
MOV BX, 00FFH
RPT: MOV AL, [SI]
CMP BH, AL
JNC LOW
MOV BH, AL ;LARGEST NUMBER IN BH
LOW: CMP BL, AL
JC SKIP
MOV BL, AL ;SMALLEST NUMBER IN BL
SKIP: INC SI
LOOP RPT
STOP: JMP STOP
Add twenty 16-bit numbers stored in data segment memory. Justify the length of the result and store in memory.
MOV AX, 1000H
MOV DS, AX
MOV SI, 100H
MOV DI, 200H
MOV BL, 02H ;LENGTH IN BYTES
MOV AX, 0000H
MOV CX, 20D/14H
RPT: ADD AX, [SI]
JNC SKIP
INC DL
SKIP: INC SI
LOOP RPT
MOV [DI], AX
INC DI
INC DI
MOV [DI], DL
CMP DL, 00H
JNZ STOP
INC BL
STOP: JMP STOP
Division of two 8-bit unsigned numbers to obtain the quotient and remainder. Refer suitable memory for different
data.
MOV AX, 2000H
MOV DS, AX
MOV SI, 100H
MOV AL, [SI]
MOV AH, 00H
MOV BL, [SI]01H
DIV BL
MOV [SI]02H, AL
MOV [SI]03H, AH
Find the number of Negative numbers in a series of 10 bytes stored from memory location 3000:0200H. Store the
results in BH register.
MOV AX, 3000H
MOV DS, AX
MOV SI, 200H
MOV CX, 10D/0AH
RPT: MOV AL, [SI]
ROL AL, 1
JNC SKIP
INC BH
SKIP: INC SI
LOOP RPT
STOP: JMP STOP
Divide two 8-bit signed numbers to obtain the quotient and remainder. Refer suitable memory for different data.
MOV AX, 2000H
MOV DS, AX
MOV SI, 200H
MOV AL, [SI]
CBW
MOV BL, [SI]01H
IDIV BL
MOV [SI]02H, AL
MOV [SI]03H, AH
Arrange a block of ten 8 bit data stored in memory location 3000:100H in ascending order.
MOV AX, 3000H
MOV DS, AX
MOV SI, 100H
MOV CH, 0AH
AGN: MOV CL, 0AH
RPT: MOV AL, [SI]
INC SI
CMP AL, [SI]
JC SKIP
XCHG AL, [SI]
DEC SI
XCHG AL, [SI]
INC SI
SKIP: DEC CL
JNZ RPT
DEC CH
JNZ AGN
STOP: JMP STOP
Transfer a block of 20 bytes from one place to other in internal memory of 8051
MOV R0, #30H
MOV R1, #50H
MOV R2, #14H
RPT: MOV A, @RO
MOV @R1, A
INC RO
INC R1
DJNZ R2, RPT
STOP: SJMP STOP
Add 10 bytes already stored in memory. Also store the result in memory in 8051.
MOV R0, #30H
MOV R1, #40H
MOV R2, #0AH
MOV A, #00H
MOV R3, #00H
RPT: ADD A, @R0
JNC SKIP
INC R3
SKIP: DJNZ R2, RPT
MOV @R1, A
INC R1
MOV @R1, R3
STOP: SJMP STOP