Hi Bruce,
I have been studying your code that you posted here on doing message tables from assembly code, and quite frankly I am baffled by parts of it. This wouldn't be problem if I could use it as is, but I really need to have the pointer increments to be by 1 (i.e.; 0,1,2,3,4,5,6, ect.).
Here are some snippits of your code with some questions I have next to them. If you get a chance can you please explain what is going on?
Code:
; This section appears to be locating the message table, but Im not
; really sure specifically what is going on especially with the first part
; where you are moving Upper msg_table into TBLPTRU
; (what is UPPER? I've used HIGH and LOW before, but never UPPER).
; TBLPTR is obviously short for Table Pointer.
movlw UPPER msg_table
movwf TBLPTRU
movlw HIGH msg_table
movwf TBLPTRH
movlw LOW msg_table
movwf TBLPTRL
; Now here we seem to be adding an offset into the message table using
; the same pointers we previously set to what I am asuming is the base
; address of our message table. This is where the beginning of a particular
; message resides within the table (correct?). Now here comes the questions
; of particular interest to me; does the fact that your pointers are in 16 byte
; increments mean that each message string can only be up to 16 bytes long?
; Or can the pointer be changed to any increment desired?
movf _ptr_pos,W ;prt_pos must hold message address
addwf TBLPTRL,F
clrf WREG
addwfc TBLPTRH,F
addwfc TBLPTRU,F
; Ok now that we have our index to a message set, we can begin retrieving
; the characters one by one, until we see the EOM character "~". What is
; tblrd *+ or more specifically *+ (is this doing a read and then increment?)
; Oh and what is "goto $-2" doing? (specifically $-2).
Next_Char
tblrd *+
movff TABLAT,_temp
bra Test_EOM ;test for EOM character
Continue
movf _temp,W ;move temp to w
movwf TXREG ;send it
btfss TXSTA,TRMT ;wait for data TX
goto $-2
bra Next_Char ;fetch next message character from table
; This part is fairly obvious, although there are some more of those $-2
; which I don't understand the purpose of, and what does "\r"
; and "\n" do? Actually to be more specific since I can see your comments,
; what my question really is; what or how does moving a literal of "\r" into
; W actually move the data (which I assume is a character from the table).
Test_EOM
movlw "~" ;check for EOM character
cpfseq _temp, 1 ;compare temp with w, if temp = ~ then end
bra Continue ;no EOM, so continue
movlw "\r" ;move data into TXREG
movwf TXREG ;send carriage return
btfss TXSTA,TRMT ;wait for data TX
goto $-2
movlw "\n" ;move data into TXREG
movwf TXREG ;send line feed
btfss TXSTA,TRMT ;wait for data TX
goto $-2
return ;finished with message, return to caller
If I was better versed in the assembly aspects of the 18F series I could probably figure this out on my own, but I only recently began working with this series of PIC chips.
Any help you can offer is appreciatted.
Thanks,
Bookmarks