Vous êtes sur la page 1sur 2

Chapter20

8096InstructionSetAndProgramming
Programming exercise
1. Write a program using 8096 mnemonics to multiply two 16-bit numbers.

LD AX, #8500H
LD BX, #900AH ; DATA1 TO B REG
LD CX, #9560 ; DATA2 TO C REG
MUL LX, BX, CX ; PRODUCT TO L REG
ST LL, [AX]+
ST LH, [AX]+
here: SJMP here

2. Write a program to search for a particular data byte in a block of internal RAM. Identify and
store the memory location of the data byte.

LD AX, #0020H
LD CL,#0AH
LD DX,#9000H
LOOP: ST [AX]+, BL
CMPB BL,#0FFH
JNE NEXT
ST AX,DX
NEXT: DJNZ CL,LOOP
here: SJMP here


3. Write a program to arrange a block of binary numbers in ascending order.
Microprocessors and Microcontrollers Kumar, Saravanan & Jeevananthan
Oxford University Press 2011

Label Mnemonics Comments
LDB BL, #9H ; Initialize outer counter (1)
LOOP2: LD CX, #8500H ; Initialize the memory pointer.
LDB BH,#09H ; Initialize inner counter (2)
LOOP1: STB [CX]+, AL ; Load data from the series in the AL register.
CMPB AL,[CX] ; Compare the number with the next number in the series.
J LE SKIP ; If it is lesser, do not interchange the numbers.
LDB AH, [CX] ; Interchange the numbers
STB AL,[CX]
DEC CX
STB AH,[CX]+
SKIP: DJ NZ BH, LOOP1 ; Decrement inner counter (2) AND LOOP if needed.
DJ NZ BL,LOOP2 ; Decrement outer counter (1) and loop if needed.
HERE: SJ MP HERE ; Terminate program execution.

4. Write a program to read a data from the input port, and then jump to different locations based on the setting of different
bits in the data.

LD AX, #000EH
LDB BL, [AX]+
J BS BL, 0, L1
J BS BL, 1, L2
J BS BL, 2, L3
J BS BL, 3, L4
J BS BL, 4, L5
J BS BL, 5, L6
J BS BL, 6, L7
J BS BL, 7, L8

Microprocessors and Microcontrollers Kumar, Saravanan & Jeevananthan
Oxford University Press 2011

Vous aimerez peut-être aussi