Open Google Drive
Q1(a) & Q10(a): 8051 Arithmetic Operations (+, -, *, /)
8051 Assembly
AIM: To develop and execute an ALP using Intel 8051 to perform arithmetic operations (addition, subtraction, multiplication, division) of two 8-bit numbers.
APPARATUS: Keil µVision5, Personal Computer
Assembly (arithmetic.a51)
ORG 0000H
; --- ADDITION ---
MOV A, #3AH
ADD A, #17H
MOV 20H, A       ; Result = 51H

; --- SUBTRACTION ---
MOV A, #7EH
CLR C
SUBB A, #2BH     ; Result = 53H
MOV 21H, A

; --- MULTIPLICATION ---
MOV A, #13H
MOV B, #0DH
MUL AB           ; 13H x 0DH = 00F7H
MOV 22H, A       ; Lower byte = F7H
MOV 23H, B       ; Upper byte = 00H

; --- DIVISION ---
MOV A, #5AH
MOV B, #0EH
DIV AB           ; 5AH / 0EH
MOV 24H, A       ; Quotient = 06H
MOV 25H, B       ; Remainder = 06H

SJMP $
END
OUTPUT: Addition: 20H = 51H | Subtraction: 21H = 53H | Multiplication: 22H = F7H, 23H = 00H | Division: 24H = 06H (Quotient), 25H = 06H (Remainder)
RESULT: Thus, the Assembly Language Program for performing arithmetic operations using Intel 8051 Microcontroller was executed successfully.
Q2(a): 8051 LED Blinking using Delay Routine
8051 Assembly
AIM: To develop and execute an ALP for Intel 8051 microcontroller to generate an LED blinking pattern using software delay routines.
APPARATUS: Keil µVision5, Personal Computer
Assembly (led.a51)
ORG 0000H
MAIN:
    SETB P1.1        ; Turn ON LED
    ACALL DELAY
    CLR P1.1         ; Turn OFF LED
    ACALL DELAY
    SJMP MAIN        ; Infinite loop

DELAY:
    MOV R7, #200
D1: MOV R6, #250
D2: DJNZ R6, D2
    DJNZ R7, D1
    RET
END
OUTPUT: Pin P1.1 continuously alternates between Logic HIGH ('1') and Logic LOW ('0'), producing square pulses / blinking LED.
RESULT: Thus, the ALP for LED Blinking using Intel 8051 Microcontroller was executed successfully.
Q3(a): 8051 Bitwise Logical Operations (AND, OR, NOT)
8051 Assembly
AIM: To develop and execute an ALP using Intel 8051 microcontroller to perform bitwise AND, OR, and NOT operations on 8-bit operands.
APPARATUS: Keil µVision5, Personal Computer
Assembly (logical.a51)
ORG 0000H
; --- AND OPERATION ---
MOV A, #12H
ANL A, #06H      ; Result = 02H
MOV 30H, A

; --- OR OPERATION ---
MOV A, #21H
ORL A, #22H      ; Result = 23H
MOV 31H, A

; --- NOT (COMPLEMENT) OPERATION ---
MOV A, #55H
CPL A            ; Result = AAH
MOV 32H, A

SJMP $
END
OUTPUT: RAM 30H = 02H (AND) | RAM 31H = 23H (OR) | RAM 32H = AAH (NOT)
RESULT: Thus, the Assembly Language Program for bitwise logical operations was executed and verified.
Q4(a): 8051 Compare Two 8-bit Numbers (>, =, <)
8051 Assembly
AIM: To develop and execute an ALP using Intel 8051 microcontroller to compare two 8-bit numbers.
APPARATUS: Keil µVision5, Personal Computer
Assembly (compare.a51)
ORG 0000H
MOV A, #35H
CJNE A, #30H, NOTEQ

EQUAL:
    MOV 4500H, #01H   ; Equal flag
    SJMP STOP

NOTEQ:
    JC LESS
GREATER:
    MOV 4501H, #01H   ; Greater flag
    SJMP STOP

LESS:
    MOV 4502H, #01H   ; Less flag

STOP: SJMP STOP
END
OUTPUT: For inputs 35H and 30H: 35H > 30H, therefore External RAM 4501H = 01H (Greater flag set).
RESULT: Thus, the ALP for comparing two 8-bit numbers using 8051 was executed successfully.
Q5(a): 8051 Decimal to Packed BCD Conversion
8051 Assembly
AIM: To develop and execute an ALP using Intel 8051 microcontroller to convert a two-digit decimal number into equivalent packed BCD format.
APPARATUS: Keil µVision5, Personal Computer
Assembly (bcd.a51)
ORG 0000H
MOV A, #45        ; Decimal 45
MOV B, #10
DIV AB            ; A = 4 (tens), B = 5 (units)
MOV R0, A
MOV R1, B

MOV A, R0
SWAP A            ; A = 40H
ORL A, R1         ; A = 45H (packed BCD)
MOV 20H, A
SJMP $
END
OUTPUT: RAM Location 20H = 45H (Packed BCD).
RESULT: Thus, decimal to packed BCD conversion was executed successfully using Intel 8051.
Q6(a): 8051 Decimal to ASCII Conversion
8051 Assembly
AIM: To develop and execute an ALP using Intel 8051 microcontroller to convert a decimal number into equivalent standard ASCII characters.
APPARATUS: Keil µVision5, Personal Computer
Assembly (ascii.a51)
ORG 0000H
MOV A, #45        ; Decimal 45
MOV B, #10
DIV AB            ; A = 4 (tens), B = 5 (units)

; Convert tens digit:
ADD A, #30H       ; 04H + 30H = 34H ('4')
MOV 30H, A

; Convert units digit:
MOV A, B
ADD A, #30H       ; 05H + 30H = 35H ('5')
MOV 31H, A

SJMP $
END
OUTPUT: Tens digit ASCII: RAM 30H = 34H ('4') | Units digit ASCII: RAM 31H = 35H ('5').
RESULT: Thus, decimal to ASCII conversion was successfully executed and verified.
Q7(a): 8051 Branching and Looping (Continuous Output)
8051 Assembly
AIM: To develop and execute an ALP to implement branching instructions and looping in Intel 8051 microcontroller to generate a continuous output.
APPARATUS: Keil µVision5, Personal Computer
Assembly (loop.a51)
ORG 0000H
MOV A, #08H
MOV P1, A

MAIN_LOOP:
    CPL A
    MOV P1, A
    ACALL DELAY
    SJMP MAIN_LOOP

DELAY:
    MOV R2, #04H
DL1:MOV R1, #04H
DL2:DJNZ R1, DL2
    DJNZ R2, DL1
    RET
END
OUTPUT: Port 1 continuously toggles between 08H and F7H.
RESULT: Thus, branching instructions and looping using 8051 were verified successfully.
Q8(a): 8051 LCD Interfacing ("HELLO WORLD")
8051 Interfacing
AIM: To interface a 16x2 LCD module to Port 1 (data) and Port 2 (control) of 8051 and display "HELLO WORLD".
APPARATUS: Keil µVision5, Proteus 8 Professional, PC
Assembly (lcd8051.a51)
ORG 0000H
RS BIT P2.0
RW BIT P2.1
EN BIT P2.2

START:
    MOV A, #38H \ ACALL CMD   ; 2 lines, 5x7 matrix
    MOV A, #0EH \ ACALL CMD   ; Display ON, cursor on
    MOV A, #01H \ ACALL CMD   ; Clear display
    MOV A, #80H \ ACALL CMD   ; Line 1, Pos 1

    ; Send "HELLO WORLD"
    MOV A, #'H' \ ACALL DATA1
    MOV A, #'E' \ ACALL DATA1
    MOV A, #'L' \ ACALL DATA1
    MOV A, #'L' \ ACALL DATA1
    MOV A, #'O' \ ACALL DATA1
    MOV A, #' ' \ ACALL DATA1
    MOV A, #'W' \ ACALL DATA1
    MOV A, #'O' \ ACALL DATA1
    MOV A, #'R' \ ACALL DATA1
    MOV A, #'L' \ ACALL DATA1
    MOV A, #'D' \ ACALL DATA1
HERE: SJMP HERE

CMD:  MOV P1, A \ CLR RS \ CLR RW \ SETB EN \ ACALL DEL \ CLR EN \ RET
DATA1:MOV P1, A \ SETB RS \ CLR RW \ SETB EN \ ACALL DEL \ CLR EN \ RET
DEL:  MOV R4, #50
DLY:  DJNZ R4, DLY \ RET
END
OUTPUT: 16x2 LCD in Proteus simulation displays: "HELLO WORLD".
RESULT: Thus, 16x2 LCD interfacing with Intel 8051 was successfully simulated and verified.
Q9(a): 8051 4x4 Matrix Keyboard Interfacing
8051 Interfacing
AIM: To interface a 4x4 matrix keyboard to Port 3 of 8051, scan rows and columns, and identify the pressed key value.
APPARATUS: Keil µVision5, Proteus 8 Professional, PC
Assembly (keypad8051.a51)
ORG 0000H
MAIN:
    MOV P3, #0FH          ; Ground rows, check columns
WAIT:
    MOV A, P3
    ANL A, #0FH
    CJNE A, #0FH, DETECT
    SJMP WAIT

DETECT:
    MOV P3, #0FEH         ; Ground Row 0
    MOV A, P3
    ANL A, #0F0H
    CJNE A, #0F0H, KEY_R0
    SJMP MAIN

KEY_R0:
    MOV 30H, #'1'         ; Store key detected
    SJMP $
END
OUTPUT: Detected key character is stored in RAM and shown on simulator output.
RESULT: Thus, the 4x4 matrix keyboard interface was executed successfully.
Q1(b): PIC16F Branching and Looping (Continuous Output)
PIC16F877A
AIM: To develop and execute an ALP to implement branching instructions and looping in PIC16F877A to generate continuous output.
APPARATUS: MPLAB IDE v8.92, Personal Computer
Assembly (loop_pic.asm)
LIST P=16F877A
INCLUDE 
ORG 0x00
MOVLW 0x55
MOVWF 0x20

MAIN_LOOP:
    COMF 0x20, F      ; Invert data (55H <-> AAH)
    CALL DELAY
    GOTO MAIN_LOOP

DELAY:
    MOVLW 0x04
    MOVWF 0x21
LOOP:
    DECFSZ 0x21, F
    GOTO LOOP
    RETURN
END
OUTPUT: Register location 20H alternates continuously between 55H and AAH.
RESULT: Thus, branching instructions and looping in PIC16F877A were verified successfully.
Q2(b): PIC16F Decimal to ASCII Conversion
PIC16F877A
AIM: To develop and execute an ALP using PIC16F to convert a decimal number into standard ASCII character codes.
APPARATUS: MPLAB IDE v8.92, Personal Computer
Assembly (ascii_pic.asm)
LIST P=16F877A
INCLUDE 
ORG 0x00
MOVLW 0x04
MOVWF 0x20          ; Tens digit = 4
MOVLW 0x05
MOVWF 0x21          ; Units digit = 5

; Convert tens:
MOVF  0x20, W
ADDLW 0x30
MOVWF 0x22          ; 22H = 34H ('4')

; Convert units:
MOVF  0x21, W
ADDLW 0x30
MOVWF 0x23          ; 23H = 35H ('5')

STOP: GOTO STOP
END
OUTPUT: File Register 22H = 34H ('4') | File Register 23H = 35H ('5').
RESULT: Thus, decimal to ASCII code conversion was verified successfully on PIC16F.
Q3(b): PIC16F Decimal to Packed BCD Conversion
PIC16F877A
AIM: To develop and execute an ALP using PIC16F to convert a two-digit decimal number into packed BCD format.
APPARATUS: MPLAB IDE v8.92, Personal Computer
Assembly (bcd_pic.asm)
LIST P=16F877A
INCLUDE 
ORG 0x00
MOVLW 0x04
MOVWF 0x20          ; Tens = 4
MOVLW 0x05
MOVWF 0x21          ; Units = 5

SWAPF 0x20, W       ; W = 40H
ANDLW 0xF0
MOVWF 0x22

MOVF  0x21, W       ; W = 05H
IORWF 0x22, W       ; W = 45H
MOVWF 0x23          ; Packed BCD = 45H

STOP: GOTO STOP
END
OUTPUT: File Register 23H = 45H (Packed BCD).
RESULT: Thus, decimal to packed BCD conversion was executed successfully on PIC16F.
Q4(b): PIC16F Bitwise Logical Operations (AND, OR, NOT)
PIC16F877A
AIM: To develop and execute an ALP using PIC16F to perform bitwise AND, OR, and NOT operations on two 8-bit operands.
APPARATUS: MPLAB IDE v8.92, Personal Computer
Assembly (logic_pic.asm)
LIST P=16F877A
INCLUDE 
ORG 0x00
MOVLW 0x55
MOVWF 0x20          ; Operand 1 = 55H
MOVLW 0x0F
MOVWF 0x21          ; Operand 2 = 0FH

; AND (55H AND 0FH = 05H):
MOVF  0x20, W
ANDWF 0x21, W
MOVWF 0x22

; OR (55H OR 0FH = 5FH):
MOVF  0x20, W
IORWF 0x21, W
MOVWF 0x23

; NOT (NOT 55H = AAH):
COMF  0x20, W
MOVWF 0x24

STOP: GOTO STOP
END
OUTPUT: 22H = 05H (AND) | 23H = 5FH (OR) | 24H = AAH (NOT).
RESULT: Thus, bitwise logical operations were verified successfully on PIC16F.
Q5(b): PIC16F Compare Two 8-bit Numbers
PIC16F877A
AIM: To develop and execute an ALP using PIC16F to compare two 8-bit numbers.
APPARATUS: MPLAB IDE v8.92, Personal Computer
Assembly (compare_pic.asm)
LIST P=16F877A
INCLUDE 
ORG 0x00
MOVLW 0x0A          ; First number = 10 (0AH)
MOVWF 0x20
MOVLW 0x0A          ; Second number = 10 (0AH)
MOVWF 0x21

MOVF  0x21, W
SUBWF 0x20, W       ; W = 0x20 - 0x21
BTFSC STATUS, Z
GOTO  EQUAL
UNEQUAL:
    MOVLW 0x00
    MOVWF 0x26      ; 0 = Not equal
    GOTO STOP
EQUAL:
    MOVLW 0x01
    MOVWF 0x26      ; 1 = Equal
STOP: GOTO STOP
END
OUTPUT: Since both operands are equal (0AH), Zero flag sets and result register 26H = 01H.
RESULT: Thus, compare operation using PIC16F was verified successfully.
Q6(b) & Q9(b): PIC16F Subtraction & Division (Repeated Subtraction)
PIC16F877A
AIM: To develop and execute an ALP using PIC16F to perform subtraction and division by repeated subtraction.
APPARATUS: MPLAB IDE v8.92, Personal Computer
Assembly (sub_div_pic.asm)
LIST P=16F877A
INCLUDE 
ORG 0x00
; --- SUBTRACTION ---
MOVLW 0x04
MOVWF 0x20          ; num1 = 4
MOVLW 0x02
MOVWF 0x21          ; num2 = 2
MOVF  0x21, W
SUBWF 0x20, W       ; W = 4 - 2 = 2
MOVWF 0x23          ; Difference = 2 in 23H

; --- DIVISION (0FH / 03H = 5) ---
MOVLW 0x0F
MOVWF 0x26          ; Dividend = 15
CLRF  0x25          ; Quotient = 0
DIV_LOOP:
    MOVLW 0x03
    SUBWF 0x26, F
    BTFSS STATUS, C
    GOTO DIV_DONE
    INCF 0x25, F
    GOTO DIV_LOOP
DIV_DONE:
STOP: GOTO STOP
END
OUTPUT: Subtraction: 23H = 02H | Division: 25H = 05H (Quotient).
RESULT: Thus, subtraction and division by repeated subtraction were verified on PIC16F.
Q7(b) & Q8(b): PIC16F Addition & Multiplication
PIC16F877A
AIM: To develop and execute an ALP using PIC16F to perform addition and multiplication of two 8-bit numbers.
APPARATUS: MPLAB IDE v8.92, Personal Computer
Assembly (add_mul_pic.asm)
LIST P=16F877A
INCLUDE 
ORG 0x00
; --- ADDITION (4 + 2 = 6) ---
MOVLW 0x04
MOVWF 0x20          ; num1 = 4
MOVLW 0x02
MOVWF 0x21          ; num2 = 2
MOVF  0x20, W
ADDWF 0x21, W
MOVWF 0x22          ; Sum = 06H in 22H

; --- MULTIPLICATION (4 x 2 = 8) ---
CLRF  0x24          ; Product = 0
MOVF  0x20, W
MOVWF 0x26          ; Counter = 4
MUL_LOOP:
    MOVF  0x21, W   ; W = 2
    ADDWF 0x24, F   ; Product += 2
    DECFSZ 0x26, F
    GOTO MUL_LOOP

STOP: GOTO STOP
END
OUTPUT: Addition Sum: 22H = 06H | Multiplication Product: 24H = 08H.
RESULT: Thus, addition and multiplication were executed and results verified on PIC16F.
Q10(b): PIC16F LCD Interfacing ("HELLO")
PIC16F Interfacing
AIM: To interface a standard 16x2 LCD module with PIC16F, configure the display, and display the message "HELLO".
APPARATUS: MPLAB IDE v8.92, Proteus 8 Professional, PC
Assembly (lcd_pic.asm)
LIST P=16F877A
INCLUDE 
ORG 0x0000
START:
    BSF STATUS, RP0
    CLRF TRISD       ; Set PORTD as output
    BCF STATUS, RP0
    CLRF PORTD

    ; Init Commands:
    MOVLW 0x38 \ MOVWF PORTD \ CALL PULSE
    MOVLW 0x0C \ MOVWF PORTD \ CALL PULSE
    MOVLW 0x01 \ MOVWF PORTD \ CALL PULSE
    MOVLW 0x80 \ MOVWF PORTD \ CALL PULSE

    ; Display "HELLO":
    MOVLW 'H' \ MOVWF PORTD \ CALL PULSE
    MOVLW 'E' \ MOVWF PORTD \ CALL PULSE
    MOVLW 'L' \ MOVWF PORTD \ CALL PULSE
    MOVLW 'L' \ MOVWF PORTD \ CALL PULSE
    MOVLW 'O' \ MOVWF PORTD \ CALL PULSE
STOP: GOTO STOP

PULSE:
    BSF PORTD, 2     ; EN = 1
    NOP
    BCF PORTD, 2     ; EN = 0
    RETURN
END
OUTPUT: 16x2 LCD in Proteus displays: "HELLO".
RESULT: Thus, LCD interfacing with PIC16F microcontroller was executed and verified.
Copied to clipboard!