Вы находитесь на странице: 1из 4

K. J.

Somaiya College of Engineering, Vidyavihar, Mumbai-77


(Autonomous College Affiliated to University of Mumbai)
Department of Electronics Engineering

Roll No. 1712116 Expt. No. 7

Title: PIC based assembly program for data transfer

Aim:
Write a PIC based assembly language program to transfer 10 bytesof data stored in program
memory with starting location 0x000050to the data register with starting address 0x0010. Use
Look uptable operations of PIC

Course Outcomes to be achieved

CO1: Use instruction set of the Microcontrollers 8051/ PIC to write simple programs.

Objective: To study lookup table instructions of PIC18F452

Algorithm:
1. To make the selection of memory from where data is to transfer
2. Load in to the Wreg registers and then transfer into another
3. Then transfer into the data register which is out destination registers
4. Similarly do for 10 bytes transfer

Department of Electronics Engineering

MCL /July-Nov19
K. J. Somaiya College of Engineering, Vidyavihar, Mumbai-77
(Autonomous College Affiliated to University of Mumbai)
Department of Electronics Engineering

Program: Attach list file with appropriate comments and snapshot of result

#INCLUDE <p18f4520.inc>

ctr equ 0x00

org 00h
bra start

org 50h
start: lfsr 0h,70h
movlw 0Ah
movwf ctr
movlw 00h
movwf TBLPTRL
movlw 03h
movwf TBLPTRH
movlw 00h
movwf TBLPTRU

repeat:tblrd*+
movf TABLAT,w
movwf POSTINC0
decf ctr
bnz repeat

last: bra last

org 300h
mydata: db 11h,22h,33h,44h,55h,66h,77h,88h,99h,89h
end

Department of Electronics Engineering

MCL /July-Nov19
K. J. Somaiya College of Engineering, Vidyavihar, Mumbai-77
(Autonomous College Affiliated to University of Mumbai)
Department of Electronics Engineering

Output:

Department of Electronics Engineering

MCL /July-Nov19
K. J. Somaiya College of Engineering, Vidyavihar, Mumbai-77
(Autonomous College Affiliated to University of Mumbai)
Department of Electronics Engineering

Post Lab Questions: Write a code to convert given single digit HEX number to its equivalent ASCII
code.

MOVR0,#20H; Initialize the address of the data


MOVA,@R0; Get the data from an address, which is stored in R0
MOVR2,A;Store the content of A into R2
CLRC; Clear the Carry Flag
SUBBA,#0AH;Subtract 0AH from A
JCNUM ; When a carry is present, A is numeric
ADDA,#41H;Add41H for Alphabet
SJMPSTORE; Jump to store the value
NUM: MOVA,R2; Copy R2 to A
ADDA,#30H; Add 30H with A to get ASCII
STORE: MOVR0,#30H; Point the destination location
MOV@R0,A; Store A content to the memory location pointed by R0
HALT: SJMPHALT

Department of Electronics Engineering

MCL /July-Nov19