Professional Documents
Culture Documents
Em Proposal
Em Proposal
ESD
“ASSIGNMENT 2”
STUDENT INFORMATION:
Sr Name Section ID E-Mail
No.
1. Muhammad 5D 01-133202-078 01-133202-
Mohsin a078@student.bahria.edu.pk
Murtaza
INSTRUCTOR:
Sr Name E-Mail
No.
1. Sohail Shehzad sohailshehzad.buic@bahria.edu.pk
Sunday, January 1, 2023
Question no 1: Produce/write an assembly code where 12 memory locations are defined. Take two
operands and store them in first two locations. Apply 2 arithmetic, 2 logical, 3 compare and 3 rotate
instructions and store their results in file registers respectively. Also show the contents of Status register and
specify the changes due to operations.
SOLUTION:
CODE:
#INCLUDE<P18F452.INC>
CONFIG WDT=OFF
ORG 00H
MOVLW 0x00
CLRF LOC8
CLRF LOC9
CLRF LOC10
MOVWF TRISB
MOVLW 0xFF
MOVWF LOC1
MOVLW 0X4E
MOVWF LOC2
MOVFF LOC1,LOC13
ADDWF LOC13,F
MOVFF LOC13,LOC3
MOVFF LOC1,LOC13
SUBWF LOC13,F
MOVFF LOC13,LOC4
MOVFF LOC1,LOC13
XORWF LOC13,F
MOVFF LOC13,LOC5
MOVFF LOC1,LOC13
IORWF LOC13,F
MOVFF LOC13,LOC6
MOVFF LOC4,LOC13
CPFSGT LOC13
MOVFF LOC13,LOC7
MOVFF LOC5,LOC13
CPFSEQ LOC13
MOVFF LOC6,LOC8
Sunday, January 1, 2023
MOVFF LOC3,LOC13
CPFSLT LOC13
MOVFF LOC13,LOC9
MOVFF LOC4,LOC13
RRNCF LOC13,F
MOVFF LOC13,LOC10
MOVFF LOC4,LOC13
RLNCF LOC13,F
MOVFF LOC13,LOC11
MOVFF LOC5,LOC13
SWAPF LOC13,F
MOVFF LOC13,LOC12
END
SCREENSHOTS:
Sunday, January 1, 2023
Question no 2: Produce/write a C18 program to convert packed BCD to 0x35 to ASCII and display
results using PORTB and PORTC. Also, write a C18 program to convert ASCII digits of ‘5’ and ‘6’ then
display on PORTC.
SOLUTION:
CODE:
#include<P18F452.h>
}
Sunday, January 1, 2023
Question no 3: Produce/write a C18 program to send out the 55H serially one bit at a time via RC0.
The LSB should go out first. Also, write a C18 program to bring in a byte of data serially one bit a time
via RC1 pin. The MSB should come in first.
SOLUTION:
CODE:
#include<P18F452.h>
}
PORTC.PC1=reg;
}
Sunday, January 1, 2023