Untitled

mail@pastecode.io avatar
unknown
abc
a year ago
12 kB
2
Indexable
Never
	# 8086 PROCEDURE:

# Procedure to word with kit: (Immediate data)
# 1. Connect the power cord and keyboard with the kit
# 2. Switch on the power supply
# 3. Press reset in the kit
# 4. Type A in the keyboard and press enter. “Line assembler” will be displayed
# 5. Starting address will be displayed in the kit. Type “1000” as starting address
# 6. Type the program and note address of each line of the code till HLT
# 7. Press reset in the kit
# 8. Type Go [space] starting address [1000]
# 9. Press enter in keyboard
# 10. “executing” message will be displayed
# 11. Press reset in kit
# 12. Give SB [memory location] [2000]
# 13. Output will be displayed

# Common commands
# 1. A – line assembler – For typing program, editing program
# 2. U – Disassembler – To check the typed program
# 3. Go – Start address – To execute the program
# 4. SB- Substituted byte – To give input & view output in memory location

# Timers/counters

# To calculate the values to be loaded into the TL and TH registers (Assume XTAL = 11.0592 MHz)
# 1.Divide the desired time delay by 1.085 us
# 2.Perform 65536 – n, where n is the decimal value we got in Step1
# 3.Convert the result of Step2 to hex, where yyxx is the initial hex value to be loaded into the timer’s register
# 4.Set TL = xx and TH = yy To generate a time delay

#Example: 250us time delay 
#Step1: 250us/1.085 us = 230pulses 
#Step2: P=65536-230=65306 
#Step3: 65306 converted by hexa decimal =FF1A 
#Step4: TH1=0xFF; TL1=0x1A;

# To	generate a time delay 
#	1. Load the TMOD value register indicating which timer (timer 0 or timer 1) and timer mode (0 or 1) is selected 
# 2. Load registers TL and TH with initial count value 
#	3. Start the timer using SETB TRx 
#	4. Keep monitoring the timer flag (TF) with the JNB TFx,target instruction 
#	5. Stop the timer using CLR TRx 
#	6. Clear the TF flag for the next round 
#	7. Go back to Step 2 to load TH and TL again

# AX = Accumulator (AH/AL)
# BX = Base address register (BH/BL)
# CX = Count Register (CH/CL)
# DX = Data Register (DH/DL)
# SI = Source index register
# DI = Destination index register
# BP = Base Pointer
# SP = Stack pointer

# DB = Define Byte
# DW = Define Word



#---------------------------------------------------------------------------------------------------------------------------------------------------------

# AVERAGE OF 3 NUMBERS

MOV BX,3H
MOV AX,2H
ADD AX,2H
ADD AX,2H
DIV BX
MOV [2000],AX
HLT

#---------------------------------------------------------------------------------------------------------------------------------------------------------

#SUM OF ARRAY OF NUMBERS

MOV CX, 05H
MOV AX,0000H
MOV BX,0000H
MOV SI,1000H
Repeat:
MOV BL,[SI]
ADD AX,BX 
INC SI
DEC CX
JNZ Repeat 
MOV DI, 1011H 
MOV [DI], AX
HLT

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# SUM OF CORRESPONDING ELEMENTS OF 2 ARRAYS

MOV SI, 100
MOV CL, [SI]
MOV CH, 00
INC SI
MOV DI, 2000
MOV AL, [SI]
ADD AL, [DI]
MOV [SI], AL
INC SI
INC DI
LOOP (address)
HLT

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# ARRANGING NUMBERS IN ASCENDING ORDER

MOV CH,04H
MOV CL,04H
MOV SI,2000
MOV AL, [SI]
MOV BL, [SI+1]
CMP AL, BL
JC 1050  # Random value is given here and then later updated
MOV DL, [SI+1]
XCHG [SI], DL
MOV [SI+1], DL
INC SI
DEC CL
JNZ 100A
DEC CH
JNZ 1003
HLT
# Now the code is again opened and then the value is updated in the first Jump statement as random value was given there.
JC 1011

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# ARRANGING NUMBERS IN DESCENDING ORDER

MOV CH,04H
MOV CL,04H
MOV SI,2000
MOV AL,[SI]
MOV BL,[SI+1]
CMP AL,BL
JNB 1070 # Random value was given here and will be updated once again
MOV DL,[SI+1]
XCHG [SI],DL
MOV [SI+1],DL
INC SI
DEC CL
JNZ 100A
DEC CH
JNZ 1003
HLT
# Now the code is again opened and then the value is updated in the first Jump statement as random value was given there.
JNB 1011

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# CONVERTING BINARY TO HEXADECIMAL (BCD TO HEX)

MOV SI,1000 
MOV DI,2000 
MOV BL,[SI] 
AND BL,0F 
MOV AL,[SI]
AND AL,F0 
MOV CL,04 
ROR AL,CL 
MOV DL,0A 
MUL DL 
ADD AL,BL 
MOV [DI],AL 
HLT

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# CONVERTING BINARY TO ASCII

MOV AL, [2000]
MOV AH, AL
AND AL, 0F
MOV CL, 04
SHR AH, CL
OR AX, 3030
MOV [3000], AX
HLT

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# FACTORIAL OF A NUMBER 

MOV CX, 04H
MOV AX, 0001
MOV BX, AX
INC BX
MUL BX
CMP BX, CX
JNZ 1050
MOV [2000], AX
HLT
# After execution as random address was given, we will again press A and give the address of the Jump statement with the correct address.
JNZ 100A # This is the correct address for the loop starting

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# PERMUTATIONS

START:
	MOV DX,0006H
	MOV CX,0004H
	SUB DX,CX
	MOV CX,DX
	MOV AX,0001H
LOOP1:
	MUL CX
	DEC CX
	JNZ LOOP1
	MOV BX,AX
	MOV CX,0006H
	MOV AX,0001H
LOOP2:
	MUL CX
	DEC CX
	JNZ LOOP2
	DIV BX
HLT

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# COMBINATION

START:
	MOV DX,0006H
	MOV CX,0004H
	SUB DX,CX
	MOV CX,DX
	MOV AX,0001H
LOOP1:
	MUL CX
	DEC CX
	JNZ LOOP1
	MOV BX, AX
	MOV CX,0004H
	MOV AX,0001H
LOOP2:
	MUL CX
	DEC CX
	JNZ LOOP2
	MUL BX
	MOV BX,AY
	MOV CX,0006H
	MOV AX,0001H
LOOP3:
	MUL CX
	DEC CX
	JNZ LOOP3
	DIV BX
	MOV [4000],AX
HLT

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# Write an 8051 assembly language program using timers to generate a frequency of 2kHz on pin port pin P2.7. 
# Assume the crystal frequency as 11.0592 MHz. (Apply Mode 1 of Timer 0).

ORG 0000H
MOV TMOD, #01H
BACK: MOV TL0, #01AH
MOV TH0, #0FFH
SETB TR0
AGAIN: JNB TF0, AGAIN
CLR TR0
CPL P2.7
CLR TF0
SJMP BACK
END

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# Write an 8051 assembly language program to toggle bit of P1.7 for every 1 second. 
# Assume the crystal frequency as 11.0592 MHz. (Apply Mode 1 of Timer 1).

ORG 0000H
MOV TMOD, #10H
REPEAT: MOV R0,#14
CPL P1.7
BACK: MOV TL1, #00H
MOV TH1, #00H
SETB TR1
AGAIN: JNB TF1, AGAIN
CLR TR1
CLR TF1
DJNZ R0, BACK
SJMP REPEAT
END

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# Assume that clock pulses are fed into pin T1 (P3.5).
# Write an 8051 assembly language program for counter 1 in mode 2 to count the pulses and display the state of the TL1 count on P1
# which connects to 8 LEDs.

ORG 000H
MOV TMOD, #60H
MOV TH1, #0
SETB P3.5
AGAIN: SETB TR1
BACK:MOV A, TL1
MOV P1, A
JNB TF1, BACK
CLR TR1
CLR TF1
SJMP AGAIN
END

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# Write a program for the 8051 to transfer “A” serially at 9600 baud, 8-bit data, 1 stop bit, do this continuously.

ORG 0000H
MOV TMOD, #20H
MOV TH1, #0FDH
MOV SCON, #50H
SETB TR1 
AGAIN: MOV SBUF,#'A'
HERE: JNB TI,HERE 
CLR TI 
SJMP AGAIN
END

#---------------------------------------------------------------------------------------------------------------------------------------------------------

#Write a program for the 8051 to transfer “VIT” serially at 9600 baud, 8-bit data, 1 stop bit, do this continuously.

ORG 0000H
MOV TMOD,#20H 
MOV TH1,#0FDH 
MOV SCON,#50H 
SETB TR1 
AGAIN: MOV A,#'V'
ACALL TRANS
MOV A,#'I' 
ACALL TRANS
MOV A,#'T' 
ACALL TRANS
MOV A,#' ' 
ACALL TRANS
SJMP AGAIN 
TRANS: MOV SBUF,A 
HERE: JNB TI,HERE 
CLR TI
RET
END

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# Write a program for the 8051 to receive bytes of data serially, and put them in P1, set the baud rate at 4800, 8-bit data, 1 start and 1 stop bit.

MOV TMOD,#20H 
MOV TH1,#0FAH 
MOV SCON,#50H 
SETB TR1 
HERE: JNB RI,HERE
MOV A,SBUF 
MOV P1,A 
CLR RI 
SJMP HERE 

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# COMPARISION OF 2 NUMBERS USING LOOPING

ORG 0000H
MOV A,#00
MOV R0,#20
LOOP: ADD A,#05
DJNZ R0,LOOP
MOV R5,A
END

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# 

ORG 0000H
MOV XA,@DPTR
MOV R0,A
INC DPTR
MOVX A,@DPTR
CLR C
SUBB A,R0
JZ EQUAL
JNC SMALL
SETB YFH
SJMP END1
SMALL: 	SETB 78H
				SJMP END1
EQUAL: 	CLR 78H
			 	CLR 7FH
END1: 	NOP
				END

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# 8051 ASSEMBLY PROGRAM TO BLOW AN LED WITH A DELAY

ORG 0000H
MOV P1,#00H
BACK: MOV A,#55H
			MOV P1,A
			SETB P1.3
			ACALL DELAY
CLR P1.3
			MOV A,#0AAH
			MOV P1,A
			ACALL DELAY
			SJMP BACK
DELAY:MOV R2,#10
AGAIN1: MOV R3,#225
AGAIN: MOV R4,#255
HERE:	NOP
			DJNZ R4,HERE
			DJNZ R3,AGAIN
			DJNZ R2,AGAIN
RET
END

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# Write an 8051 assembly language program to display the message “VIT” on LCD display

ORG 0000H
MOV A, #38H
ACALL COMNWRT
ACALL DELAY 
MOV A, #0EH 
ACALL COMNWRT 
ACALL DELAY 
MOV A, #01 TV
ACALL COMNWRT 
ACALL DELAY 
MOV A, #06H 
ACALL COMNWRT
ACALL DELAY
MOV A, #84H 
ACALL COMNWRT 
ACALL DELAY 
MOV A, #'V' 
ACALL DATAWRT 
ACALL DELAY 
MOV A, #„I' 
ACALL DATAWRT 
ACALL DELAY 
MOV A, #„T' 
ACALL DATAWRT 
AGAIN: 
	SJMP AGAIN 
	COMNWRT
	MOV P2, A
	CLR P3.7 
	CLR P3.6 
	SETB P3.5 
	ACALL DELAY 
	CLR P3.5 
	RET
DATAWRT: 
	MOV P2, A 
	SETB P3.7 
	CLR P3.6 
	SETB P3.5 
	ACALL DELAY
	CLR P3.5 
	RET
DELAY: MOV R3, #50 
HERE2: MOV R4, #255 
HERE: 
	DJNZ R4, HERE 
	DJNZ R3, HERE2
	RET
END

#---------------------------------------------------------------------------------------------------------------------------------------------------------

# Write an 8051 assembly language program to display the message “VIT University” on LCD display using DPTR.

ORG 0000H
MOV DPTR, #MYCOM
C1: 
	CLR A
	MOVC A,@A+DPTR
	ACALL COMNWRT
	ACALL DELAY
	INC DPTR
	JZ SEND_DAT
	SJMP C1
SEND_DAT: MOV DPTR, #MYDATA
D1: 
	CLR A
	MOVC A,@A+DPTR
	ACALL DATAWRT
	ACALL DELAY
	INC DPTR
	JZ AGAIN
	SJMP D1
AGAIN: SJMP AGAIN
COMNWRT: 
	MOV P2, A 
	CLR P3.7 
	CLR P3.6 
	SETB P3.5 
	ACALL DELAY 
	CLR P3.5 
	RET
DATAWRT: 
	MOV P2, A 
	SETB P3.7 
	CLR P3.6 
	SETB P3.5 
	ACALL DELAY
	CLR P3.5 
	RET
DELAY: MOV R3, #250 
HERE2: MOV R4, #255 
HERE: 
	DJNZ R4, HERE 
	DJNZ R3, HERE2
	RET
	ORG 300H
MYCOM: DB 38H, 0EH, 01, 06, 84H, 0 
MYDATA: DB “VIT University”, 0

END
Thank you Hemant Bhai