Maker Pro
Maker Pro

PIC dt directive

A

Andrew Rich

Gudday

How does this work and how do you call it in assembly ?

TAB addwf PCL,F ; Move offset to PC lower

DT "PROGRAM TEST RS232 PORT ON CPU PIC16F877 RUN FREQ
10MHz",0X0A,0X0D
 
DT will produce a series of RETLW kk instructions. For example the
code you supplied is the equivalent of:


TAB addwf PCL,f ; Move offset to PC lower

retlw 0x50 ; ASCII "P"
retlw 0x52 ; ASCII "R"
retlw 0x4F ; ASCII "O"
retlw 0x47 ; ASCII "G"
retlw 0x52 ; ASCII "R"
retlw 0x41 ; ASCII "A"
 
N

NewsGroup

DT gets turned into a lot of retlw instructions. Try looking at the
disassembly code in MPLAB.

You need to make sure that it is all contained in the same 256 byte block.
You then call TAB with W containing the offset to the character you want.

Mike.
 
A

Andrew Rich

Ta - I get that dt is the same as retlw,

Have some more questions

1. What is this doing ? addwf PCL,f

Thats says to me add what is in W to PCL.

But PCL is the program counter ?

2. This seems to make no sense

movwf 0x00

move w into f, to where ? 0x00 ?
 
A

Andrew Rich

Ok I did it in MPLAB and all is good

movlw 0x00 ; set start of table
movwf offset ; set this for the TAB function

here movfw offset ; move into W, offset in table
call TAB ; get the character from the table, according to
offset
movwf TXREG ; send that character out (ignoring hand shaking)
incf offset,f ; get the next character by inc offset
goto here ; Send again

TAB addwf PCL,F ; Move offset to PC lower
DT "PROGRAM TEST RS232 PORT ON CPU PIC16F877 RUN FREQ
10MHz",0X0A,0X0D
end ;end progra
 
1. Yes you're correct. You are adding an offset (which is in W) to
the program counter. This allows you to select which particular
"retlw" you want to use.

2. Yes you're correct. It makes no sense because I made a
mistake :) They should be (as you've worked out) "movlw 0x00" and
"movlw 0x03" in my examples, NOT "movwf"
 
Top