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

Itlab

The document contains assembly language programs (ALPs) for various tasks involving 8086, 8051 and stepper motor control. 1) One ALP generates square and triangular waves using an 8-bit DAC and 8086 assembly language. 2) Another controls stepper motor speed and direction using an 8051 microcontroller. 3) Other ALPs interface a keyboard and move blocks of data using 8086 and 8051 instructions.

Uploaded by

krishna_cad28
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)
32 views

Itlab

The document contains assembly language programs (ALPs) for various tasks involving 8086, 8051 and stepper motor control. 1) One ALP generates square and triangular waves using an 8-bit DAC and 8086 assembly language. 2) Another controls stepper motor speed and direction using an 8051 microcontroller. 3) Other ALPs interface a keyboard and move blocks of data using 8086 and 8051 instructions.

Uploaded by

krishna_cad28
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/ 14

Please copy

8,9,10,11a,12,13 in
your observations
8. DAC Interface-Waveform generations
Aim: 8086 Assembly language to interface a 8‐bit D‐A converter and convert digital to analog
(generate square and triangular)

Algorithm:

i) This program is for ESA 86/88E monitor version 3.0


ii) Assume the interface is connected over of the trainer.
iii) In serial mode or LCD in stand alone mode of the operation in it.
iv) This program can be executed in stand –alone mode or serial mode of operation.
v) The program starts at memory location.

Procedure:

i) An algorithm is developed solve the given problem statement


ii) The program code is saved in a serial mode of operation
iii) Reset status is used when contents to use RAM or not distributed it on the board.
iv) Go command is used for users description to be evaluated.

Assembly language program:

START: MOV DX, OFFE6

MOV AL, 80 ; Initialize 8255

OUT DX, AL ; all ports as o/p

MOV CX, OFF ; set count

MOV AL,00; Start from 0

UP : INC AL; Increment data for positive going slope

MOV DX, AL

OUT DX, AL

MOV DX, OFFE2

OUT DX, AL

LOOP UP

MOV CX, OFF; Set count start from FF

MOV AX, CX
POWN: DEC AL

MOV DX, OFFED

OUT DX, AL

MOV DX, OFFE2

OUT DX, AL

LOOP DOWN

JMP START

Program code for Square Wave:

START: MOV AL, 80

MOV DX, OFFE6

OUT DX, AL

MOV AL, OFF

MOV DX, OFFE0

OUT DX, AL

MOV CX, OFF

DLY1: LOOP DLY1

MOV AL,00

MOV DX, OFFEO

OUT DX, AL

MOV CX, OFF

DLY2: LOOP DLY2; DELAY 2

JMP START; repeat continuously

R.V.R & J.C College of Engineering, Guntur‐ 19 Page No. 30


9. Stepper Motor Control.
Aim: To write an ALP to control the stepper motor and its speed of operation

Algorithm:

i) This program makes the stepper motor to rotate the stepper motor in left (or) right
direction with required speed
ii) This program is in serial mode or LCD mode alone of operation
iii) The program is executed in stand alone mode (or) serial mode of operation
iv) The program starts at memory location of 0:5000H

Procedure:

i) This program is developed to solve given problem.


ii) The program code is in serial mode of operation
iii) RESET status are used when the contents of user RAM are not distributed it on board.
iv) Program displays the speed of operation of stepper motor and its rotation in different
directions

Assembly language program:


5000: MOVB AL, 80; initialize 8255
MOVW DX, OFFE6
OUT DX, AL
MOVB AL,88
5008: LOOP: MOVW DX, OFFE0
OUT DX, AL
CALL DELAY
XCHG AX, AV
RORB AL,01
JMP LOOP
5014: DELAY: PUSHF
PUSH AX
MOVW BX, OFFF
5019: GO: DECW BX
JNZ GO
POP AX
POPF
RET

R.V.R & J.C College of Engineering, Guntur‐ 19 Page No. 31


10. Keyboard Interface
Aim: To write an ALP to interface the keyboard using 8086 microprocessor

Algorithm:

This program is for ESA 86/88E monitor version 3.0

i) Assume the interface is connected over J4 of the trainer

ii) This program displays the value of the pressed key on the pc console

iii) In serial mode or LCD in stand alone mode of operation

iv) This program can be executed in stand alone mode (or) serial mode of operation

v) This program starts at memory location 0:20004

vi) Please refer ESA 86/88E users manual for mnemonic systax

Procedure:

i) An algorithm is developed

ii) Solve given problem statement

iii) The program code is saved in a serial mode operation

iv) Reset status is used when the contents to use RAM or not distributed it on board

v) Go command is used for suers description program

Assembly Level Program:

[Symbolic Assembler Program(T0 be used with ESA – 86 only)

ADDRESS OPCODE LABEL MNEMONIC COMMENTS

2000 B8 00 00 MOV AX,0000H

2003 8E C0 MOV ES,AX

2005 BA E6 FF MOV DX,0FFE6H ;Configure 8255 in mode 0

2008 B0 92 MOV AL,92 ;PortA as i/p

200A EE OUT DX,AL ;Port C as o/p

R.V.R & J.C College of Engineering, Guntur‐ 19 Page No. 32


200B EB 0F JMP START

200D 4B 45 59 MES:
20 50 52
DB ‘KEY
2013 45 53 53 PRESSED=’,0H
45 44 20

2019 3D 20 00

201C 9A 31 00 START: CALLS 0FE00:0031 ; new line


00 FE

2021 2E CS

2022 8D 16 0D LEA DX, @MES


20

2026 8B C2 MOV AX,DX

2028 9A 13 00 CALLS 0FE00:0013 ;call for displaying the


00 FE message

202D E8 05 00 CALL KSCAN

2030 E8 3D 00 CALL DELAY

2033 EB E7 JMP START

2035 B1 01 KSCAN: MOV CL,01

2037 8A C1 NEXT: MOV AL,CL ;make one of scan lines high

2039 BA E4 FF MOV DX,0FFE4

203C EE OUT DX,AL

203D BA E0 FF MOV DX,0FFE0

2040 EC IN AL,DX

2041 8A E0 MOV AH,AL ;check for key

2043 0A 0C OR AL,AL ;pressed?

2045 75 0A JNZ KEYCODE ;if yes,detect

2047 D0 C1 CONT: ROL CL,1

2049 80 F9 08 CMP CL,08

R.V.R & J.C College of Engineering, Guntur‐ 19 Page No. 33


204C 74 E7 JE KSCAN

204E E9 E6 FF JMP NEXT

2051 B3 00 KEYCODE: MOV BL,0H ;detect coloumn

2053 8A C4 MOV AL,AH

2055 D0 E8 SHIFT: SHR AL,1

2057 3C 00 CMP AL,00

2059 74 05 JZ ROW

205B FE C3 INC BL ;increment coloumn

205D E9 F5 FF JMP SHIFT ;count and repeat

2060 8A C1 ROW: MOV AL,CL ;detect rpw

2062 B1 02 MOV CL,02

2064 D2 C0 ROL AL,CL

2066 24 FB AND AL,0FB

2068 0A C3 OR AL,BL

206A 9A 52 00 CALLS 0FE00:0052


00 FE

206F C3 RET

2070 51 DELAY: PUCH CX

2071 B9 00 00 MOV CX,00 ; delay routine

2074 E2 FE DLY: LOOP DLY

2076 59 POP CX

2077 C3 RET

11. Programs on Data Transfer Instructions Using 8051 Microcontroller

R.V.R & J.C College of Engineering, Guntur‐ 19 Page No. 34


11a) Aim:Write an ALP to move a block of 16 bytes of data from program
memory(ROM) starting at 9000 location to data memory(RAM) starting at 9000
location.

Algorithm:

i) This program is for ESA 86/88E monitor version of 3.0

ii) Assume the interface is connected over j4 of trainer

iii) This program move a block of 16 bytes of data from program memory to data memory

iv) The program can be executed in stand alone mode or serial mode of operation

v) The program starts memory at 0:9000H

Procedure:

i) An algorithm is developed to solve given problem statement

ii) The program code is saved in serial mode operation

iii) RESET Status is used when the contents of user RAM are not disturbed it on board.

iv) Load data in program memory at 9000 memory location using MP 9000 command.

v) For compile the program we use g 8000

vi) After execution read the data at location from MD 9000

Assembly language program:


MOV DPTR, # 9000

MOV R2, # 10

L1: CLR A

MOVC A, @ A+DPTR

MOVX @ DPTR, A

INC DPTR

DJNZ R2, L1

LIMP 0

R.V.R & J.C College of Engineering, Guntur‐ 19 Page No. 35


11b) Aim: Write an ALP to move a Block of Data from one memory location to another
location.
Objective: To write three sub-routines (a)to transfer the data from on-chip ROM to RAM
location starting at 30H (a)to add the data and save in 20H (c)to find the average of the data
and store it in R7.
Assembly language program:

LCALL SR1 SR2: MOV R0, #30


LCALL SR2 MOV R2, #04
LCALL SR3 CLR A
SR1: MOV DPTR, #9100 L2: ADD A, @R0
MOV R0, #30 MOV 20H, A
MOV R2, #04 INC R0
L1: CLR A DJNZ R2, L2
MOVC A, @A+DPTR RET
MOV @R0, A SR3: MOV F0, #04
INC DPTR DIV AB
INC R0 MOV R7,A
DJNZ R2, L1 RET
RET
Additional Program

Aim: Write an ALP to move a Block of Data from one memory location to another location.

Assembly language program:

ORG 0H STOREDATA2: MOV DPTR, #MYDATA1


CONT2: CLR A
LJMP MAIN MOVC A, @A+DPTR
ORG 10H JZ DO_SWAP
MYDATA0: DB "DEAR STUDENTS",0 MOV @R0,A
INC R0
ORG 30H INC DPTR
MYDATA1: DB "DEAR TEACHER ",0 SJMP CONT2
DO_SWAP: MOV R1, #DADD1
ORG 100H MOV R0, #DADD2
DADD1 EQU 30H BACK: CLR A
DADD2 EQU 60H
MAIN: MOV R1, #DADD1 MOV A, @R1
MOV R0, #DADD2 JZ HERE
MOV DPTR, #MYDATA0 XCH A,@R0
CONT1: CLR A XCH A,@R1
MOVC A, @A+DPTR INC R0
JZ STOREDATA2
MOV @R1,A INC R1
INC R1 SJMP BACK
INC DPTR HERE: SJMP HERE
SJMP CONT1 END

R.V.R & J.C College of Engineering, Guntur‐ 19 Page No. 36


12.Programs on Arithmetic and Logical Instructions using 8051
Microcontroller.
12a) Aim: Write an ALP using 8051 to perform multiplication of two 8 bit numbers
Assembly language program:

MOV DPTR, # 9000; Keep data in


MOVX A, @ DPTR; 9000 & 9001
MOV OFO, A; Data Memory
MOV DPTR, # 9001; Location
MOV A, @ DPTR
MUL AB; Perform multiplication Operation
MOV DPTR, # 9002; Store the result
MOVX @ DPTR, A; in 9002 & 9003
INC DPTR; of data memory
MOV A, OFO
MOVX @DPTR, A
LJMP 0

12b) Aim: Write an ALP using 8051 to perform division of two 8 bit numbers

MOV DPTR, # 9001; Keep data in


MOVX A, @ DPTR; 9000 and 9001 data
MOV 0F0, A; memory location
MOV DPTR, # 9000
MOVX A, @ DPTR
DIV AB; Perform division operation
MOV DPTR, # 9002; Store the result in
MOVX @DPTR, A; 9002 & 9003 data memory
INC DPTR
MOV A, 0F0
MOVX @ DPTR, A
LJMP 0
12c) Aim:Write an ALP using 8051 to check whether the 5th bit is ‘1’ or ‘0’ in a given
byte. If the 5th bit is ‘1’ 00 should be stored at location 8901 in data memory or if it is
‘0’ FF should be stored at location 8901 in data memory.

Assembly language program:


MOV DPTR, # 8900
MOVX A, @ DPTR
INC DPTR
RLC A
RLC A
RLC A
JC LOOP C=1
MOV A, #OFF
MOVX @DPTR, A

R.V.R & J.C College of Engineering, Guntur‐ 19 Page No. 37


LJMP 3
LOOP MOV A, # 00
MOVX @ DPTR, A
LIMP 0

Additional Programs:

1.Aim: To add 5 BCD data items that are stored in RAM locations starting at 30H.

Example:

Sample Data:

[30] = 01

[31] = 02

[32] = 03

[33] = 04

[34] = 05

Result:A = 15

Assembly language program:

MOV 30, #01 AGAIN: ADD A, @R0


MOV 31, #02 DA A
MOV 32, #03 JNC NEXT
MOV 33, #04 INC R7
MOV 34, #05 NEXT: INC R0
MOV R0, #30H DJNZ R2,AGAIN
MOV R2, #5 RET
CLR A
MOV R7, A
2. Aim: Write an ALP to perform 8 bit addition.

//VALUES TO BE ADDED IS STORED IN CODE MEMORY LOCATION STARTING FROM


10H THE VALUES WILL TERMINATE WITH A ZERO

Assembly language program:

ORG 00H JZ ADD_NUM


LJMP MAIN MOV @R0,A
ORG 10H INC R0
MYDATA0: DB 1,2,3,15,26,89,124,0 INC DPTR
ORG 100H SJMP CONT1
MAIN: MOV DPTR, #MYDATA0 ADD_NUM: MOV R0,#30H
MOV R0,#30H MOV A,#00H
MOV R2,#00H ADDING: MOV A,R3
CONT1: CLR A ADD A, @R0
MOVC A,@A+DPTR JNC SIMPLY_ADD

R.V.R & J.C College of Engineering, Guntur‐ 19 Page No. 38


INC R2 MOV 71H,R3
SIMPLY_ADD: INC R0 HERE: SJMP HERE
MOV R3,A
MOV A,@R0
JNZ ADDING
MOV 70H,R2

3.Aim: Write an ALP to perform 8 bit Subtraction

Assembly language program:

ORG 0H ; START AT LOCATION 0 (ORIGIN)


CLR C ; CLEAR CARRY FLAG
MOV A,#7CH ; LOAD 4CH IN TO A
SUBB A,#7EH ; SUBTRACT 6E FROM A
JNC NEXT ; IF CARRY =0 JUMP TO NEXT TARGET
CPL A ; IF CARRY =1 TAKE ONE'S COMPLIMENT
INC A ; AND INCREMENT TO GET 2'S COMPLINENT
NEXT: MOV R1,A ; SAVE A IN R1
HERE: SJMP HERE

4.Aim: To understand the basic Logical byte operations.

Assembly language program:

ORG 00H RR A //rotate right logical


MOV R0, #34H operations
MOV A, R0 RR A
ANL A, #0FH //and logical RR A
operation RR A
MOV P1, A
MOV A, R0
ORL A, #0FH //or logical MOV P1, A
operations MOV A, R0
MOV P1, A RL A //rotate left logical
MOV A, R0 operations
XRL A, #0FH //exclusive or RL A
operations RL A
MOV P1, A RL A
MOV A, R0 MOV P1, A
CPL A //complement logical MOV A, R0
operations SETB C
MOV P1, A RRC A //rotate right with carry
MOV A, R0 RRC A
CLR A //clear logical operations RRC A
MOV P1, A RRC A
MOV A, R0 MOV P1, A

R.V.R & J.C College of Engineering, Guntur‐ 19 Page No. 39


MOV A, R0 MOV P1, A
RLC A //rotate left with carry SJMP $
RLC A END
RLC A
RLC A
5.Aim: To understand the basic Logical bit operations.

Assembly language program:

SETB 01H //set bit addressible memory 01h

CLR 01H //clear bit addressible memory 01h

CPL 01H //compliment bit addressible memory 01h

MOV C, 01H //move bit addressible memory location 01h's content to carry

MOV 07FH, C //move carry to bit addressible memory location 01h

SETB 01H

ANL C, 01H //logically and bit addressible memory 01h content with carry

ORL C, 01H //logically or bit addressible memory 01h content with carry

SJMP $ END

13. Applications with Microcontroller 8051


Aim: To generate the time delay by programming the 8051 timers.

Example:

Assume XTAL =20 MHz

R.V.R & J.C College of Engineering, Guntur‐ 19 Page No. 40


The timer works with a clock frequency of 1/ 12 of the XTAL frequency; therefore, we have 20
MHz / 12 = 1.6666MHz as the timer frequency. As a result, each clock has a period of T = 1 /
1.666 MHz = 0.6002 µs. In other words, timer 0 counts up each 0.6002 µs resulting in a delay
= number of counts × 0.6002 µs.

The number of counts for the roll over is FFFH – 0000H = FFFFH ( 65535 D ).

However we add one to 65535 because of the extra clock needed when it rolls over from
FFFF to 0 and raises the TF flag. This gives 65535 × 0.6002 µs = 39.334 ms for half the
pulse. For the entire period it is T = 2 × 39.334 ms = 78.668 ms as the time delay generated
by the timer

Assembly language program:


,

MOV TMOD, #01

HERE: MOV TL0,

#00

MOV TH0,

#00 CPL P1.5

LCALL DELAY

SJMP HERE

DELAY: SETB TR0

AGAIN: JNB TF0,

AGAIN

CLR

TR0

CLR TF0

RET

R.V.R & J.C College of Engineering, Guntur‐ 19 Page No. 41

You might also like