MICRO LAB EXAMPLES - (ECE3003)

Program 1.
Write and assemble a program to add the following data and then use the simulator to examine the CY flag.

Code:
ORG 0000H
MOV A,#92H
MOV R0,#23H
ADD A,R0
JNC L1
INC R7
L1:
MOV R1,#66H
ADD A,R1
JNC L2
INC R7
L2:
MOV R2,#87H
ADD A,R2
JNC L3
INC R7
L3:
MOV R3,#0F5H
ADD A,R3
JNC L4
INC R7
L4:
END

Program 2.
Write and assemble a program to load the values into each register R0-R4 and then push each of these registers onto the stack. Single Step program and examine the stack and the SP register after execution of each instruction.

Code:
ORG 0000H
MOV R0,#25H
MOV R1,#35H
MOV R2,#45H
MOV R3,#55H
MOV R4,#65H
PUSH 0
PUSH 1
PUSH 2
PUSH 3
PUSH 4
END

Program 3.
Add the following subroutine to the previous program, single step through the subroutine and examine the RAM locations. After data has been transferred from ROM space into RAM, the subroutine should copy the data from RAM locations starting at 40H to ROM locations starting at 60H.

Code:
ORG 0000H
MOV DPTR,#200H
MOV R0,#40H
MOV R1,#0EH
LOOP:CLR A
MOVC A,@A+DPTR
MOV @R0,A
INC R0
INC DPTR
DJNZ R1,LOOP
MOV R0,#40H
MOV R1,#60H
MOV R3,#0EH
LOOP2:CLR A
MOV A,@R0
MOV @R1,A
INC R0
INC R1
DJNZ R3,LOOP2
HERE:SJMP HERE
ORG 200H
DB "VIT UNIVERSITY"
END

Program 4. Write a program to calculate y where y=x2+2x+9, x is between 0 to 9 and the look up table for x2 is located at the address of 200H. Register R0 has the x and at the end of program R2 should have y. Use simulator to change the value of x and single step through the program,examining the registers as you go.

Code:
ORG 0000H
MOV DPTR,#200H
MOV A,#03H
MOV R1,A
MOV R0,A
ADDC A,R1
MOV R1,A
MOV A,R0
MOVC A,@A+DPTR
ADDC A,#09H
ADDC A,R1
MOV R2,A
HERE:SJMP HERE
ORG 200H
DB 00H,01H,04H,09H,10H,19H,24H,31H,40H,51H
END

Program 5. Write and assemble a program to toggle all the bits of P0, P1 and P2 continuously by sending 55H and AAH to these ports. Put a time delay between ON and OFF.

Code:
ORG 0000H
HERE : MOV P0,#55H
MOV P1,#55H
MOV P2,#55H
ACALL DELAY
MOV P0,#0AAH
MOV P1,#0AAH
MOV P2,#0AAH
ACALL DELAY
SJMP HERE
DELAY : MOV R1,#200
BACK : MOV R2,#200
AGAIN : DJNZ R2,AGAIN
DJNZ R1,BACK
RET
END

Program 6. Get the data from P1 and send it to P2. Use P1 as input and put P2 as output port.

Code:
MOV A,#0FFH
MOV P1,A
HERE : MOV A,P1
MOV P2,A
SJMP HERE
END


Program 7. Continuously scan the port P0. If data is other than FFH, write a subroutine then multiply it with 10d and send it to P1.

Code:
HERE: MOV P0,#0FFH
LOOP: MOV A,P0
CJNE A,#0FFH,CMP
SJMP LOOP
CMP:ACALL MULTI
SJMP HERE
MULTI:
MOV B,#10d
MUL AB
MOV P1,A
RET
END


Program 8. BCD

Code:
ORG 120H
DB 54H,76H,65H,98H
ORG 150H
DB 93H,56H,97H,38H
ORG 00H
MOV DPTR,#120H
MOV R4,#05H
MOV R0,#40H
MOV R3,#00H
LOOP:CLR A
MOVC A,@A+DPTR
MOV R3,A
MOV A,#30H
MOVC A,@A+DPTR
ADDC A,R3
DA A
MOV @R0,A
INC R0
INC DPTR
DJNZ R4,LOOP
HERE:SJMP HERE
END

Program 9.
Write a program using timer 0 to generate a 500Hz square wave frequency on one of the pins of P1.0 Then examine the frequency using the KEIL IDE inbuilt logic Analyzer using Mode 1.

Code:
ORG 0000H
MOV TMOD,#01H
HERE:MOV TL0,#66H
MOV TH0,#0FCH
CPL P1.0
ACALL DELAY
SJMP HERE
DELAY:
SETB TR0
AGAIN:JNB TF0, AGAIN
CLR TR0
CLR TF0
RET
END

Program 10.
Write a program using timer 0 to generate a 1kHz square wave frequency on one of the pins of P1.0 Then examine the frequency using the KEIL IDE inbuilt logic Analyzer using Mode 1.

Code:
ORG 0000H
MOV TMOD,#01H
HERE:MOV TL0,#33H
MOV TH0,#0FEH
CPL P1.0
ACALL DELAY
SJMP HERE
DELAY:
SETB TR0
AGAIN:JNB TF0, AGAIN
CLR TR0
CLR TF0
RET
END

Program 11.
Assuming that clock pulses are fed into pin T1, write a program for counter 1 in mode 2 tocount the pulses and display the state of the TL1 count on P2, which connects to 8 LEDs.(Software Implementation)

Code:
MOV TMOD,#01100000B                     ;counter 1,mode 2,
                                                                ;C/T=1 external pulses
MOV TH1,#0
SETB P3.5
AGAIN: SETB TR1
BACK: MOV A,TL1
MOV P2,A
JNB TF1,BACK
CLR TR1
CLR TF1
SJMP AGAIN
END

Program 12.
Use Counter 1 in mode 2 and after 10 number of counts on TL1, generate a square waveform of 1 KHz on P1.2 by using Timer 0 in mode 1, shows the counts in TL1 on port 2

Code:
ORG 0000H
MOV TMOD,#01100001B
MOV TH1,#0
SETB P3.5
AGAIN:
SETB TR1
BACK: MOV A,TL1
MOV P2,A
CJNE A,#0AH,BACK
CLR TR1
HERE:
MOV TL0,#33H
MOV TH0,#0FEH
CPL P1.2
ACALL DELAY
SJMP HERE
DELAY: SETB TR0
GAIN: JNB TF0,GAIN
CLR TR0
CLR TF0
CLR TR1
CLR TF1
SJMP AGAIN
RET
END

Program 13. Write an 8051 assembly program to transfer data serially at baud rate 9600 with 8 bit data,one stop bit and observe the transmitted data in the serial window of the simulator.

Code:
ORG 0000H
XX: MOV DPTR,#MYDATA
MOV TMOD,#20H
MOV TH1,#-3
MOV SCON,#50H
SETB TR1
MOV R1,#14
AGAIN:CLR A
MOVC A,@A+DPTR
MOV SBUF,A
HERE: JNB TI,HERE
CLR TI
INC DPTR
DJNZ R1,AGAIN
SJMP XX
MYDATA: DB 'VIT UNIVERSITY'
END


Program 14.
Write a 8051 assembly language program to get data from the PC and display it on P1. Assume 8051 is connected to PC and observe the incoming characters. As you press a key on the PC's keyboard, the character is sent to 8051 serially at 4800 baud rate and is displayed on LED's. The characters displayed on LED's are in ASCII (binary)

Code:
ORG 0000H
MOV TMOD,#20H
MOV TH1,#-6
MOV SCON,#50H
SETB TR1
HERE: JNB RI,HERE
MOV A,SBUF
MOV P1,A
CLR RI
SJMP HERE
END

Program 15. Write a program to the send the message 'India is our country' to serial port. Assume a sw is connected to pin P1.2

Monitor its status and set the baud rate as follows:-
SW=0 4800
SW=1 9600
XTAL = 11.0592MHZ, 8 bit data and 1 stop bit

Code:
ORG 0000H
HERE:
MOV TMOD,#20H
MOV TH1,#-6
MOV SCON,#50H
SETB TR1
SETB P1.2
SW1:JNB P1.2,XX
MOV A,PCON
SETB ACC.7
MOV PCON,A
SJMP HERE2
XX:
MOV A,PCON
SETB ACC.7
MOV PCON,A
HERE2: MOV DPTR,#MYDATA
BACK:CLR A
MOVC A,@A+DPTR
JZ SW1
ACALL TRANS
INC DPTR
SJMP BACK
TRANS:
MOV SBUF,A
HERE1: JNB TI,HERE1
CLR TI
RET
MYDATA: DB 'India is Our Country'
END

Program 16.
Write an 8051 program to get data from port P0 and send it to port P1 continuously while an interrupt will do the following: timer 0 will toggle the P2.1 bit every 100 microseconds.

Code:
ORG 0000H
LJMP MAIN
ORG 000BH
CPL P2.1
RETI
ORG 0030H
MAIN:
MOV TMOD,#02H
MOV P0,#0FFH
MOV TH0,#0A4H
MOV IE,#10000010B
SETB TR0
BACK: MOV A,P0
MOV P1,A
SJMP BACK
END

Program 17.
Write and 8051 program to get data from a single bit of P1.2 and send it to P1.7 continuously while an interrupt will do the following: A serial interrupt service routine will receive data from a PC and display it on P2 ports.

Code:
ORG 0000H
LJMP MAIN
ORG 0023H
LJMP SERIAL
ORG 0030H
MAIN:
SETB P1.2
MOV TMOD,#20H
MOV TH1,#-3
MOV SCON,#50H
MOV IE,#10010000B
SETB TR1
BACK:
MOV C,P1.2
MOV P1.7,C
SJMP BACK
SERIAL:
JB TI,TRANS
MOV A,SBUF
MOV P2,A
CLR RI
RETI
TRANS:
CLR TI
RETI
END

Program 18. Write a program using interrupts to do the following:
a) Receive data serially and send it to P0
b) Have P1 port read and transmitted serially, and a copy given to P2
c) Make a timer o generate a square wave of 5 kHz frequency on P3.2
Assume that XTAL is 11.0592MHz, Set baud rate at 4800

Code:
ORG 0000H
LJMP MAIN
ORG 000BH
CPL P3.2
RETI
ORG 0023H
SERIAL
ORG 0030H
MAIN:
MOV P1,#0FFH
MOV TMOD,#22H
MOV TH1,#-6
MOV SCON,#50H
MOV TH0,#0A4H
MOV IE,#10010010B
SETB TR1
SETB TR0
BACK: SJMP BACK
SERIAL:JB TI,TRANS
MOV A,SBUF
MOV P0,A
CLR RI
RETI
TRANS: CLR TI
RETI
END

Comments

  1. Binance account frozen error? This error might seem difficult but what actually difficult is to fix it which is out of the scope of a user who just has joined or holds less information about the exchange. If you are looking for ways and means to deal with this a bummer all at once, you can always call on Binance customer support number which is always functional. You can have conversation with them related to every type of Binance error and avail out-of-the-box remedies from the professionals in nick of time.

    ReplyDelete
  2. Write a program to transfer a string of data from code space



    starting at address 200H to RAM locations starting at 40H. The data is as shown below:


    0200H:DB "VIT UNIVERSITY"


    Using the simulator, single-step through the


    program and examine the data transfer and registers.

    ReplyDelete
  3. Write an 8051 assemble language program to:



    (a) Set SP = 0D,


    (b) Load a different value in each of RAM locations 0D, 0C, 0B, 0A, 09, and 08,


    (c) POP each stack location into registers R0 - R4. Use the simulator to single-step and examine the registers, the stack, and the stack pointer.

    ReplyDelete

Post a Comment

Popular posts from this blog

Lattice Ladder Structure - (ECE-2006)

Line Coding PSD - (ECE-4001)