Exact match. Not showing close matches.
PICList
Thread
'[PIC]:understanding code for a newbie'
2001\02\08@155533
by
cas Fenoll Molina
Hi, could anyone explain to me how this code works?
Thanks in advance
MnLoop clrf MessPt
movlw 0x80 ; line 1
call LCDins
Loop1 call TheText
xorlw 0h
btfsc STATUS,Z
goto DoLine2
call LCDout
incf MessPt
goto Loop1
DoLine2 incf MessPt
movlw 0xC0 ; line 2
call LCDins
Loop2 call TheText
xorlw 0h
btfsc STATUS,Z
goto DoDelay
call LCDout
incf MessPt
goto Loop2
DoDelay call BigDel ; wait
goto MnLoop
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
2001\02\08@162636
by
Drew Vassallo
|
>Hi, could anyone explain to me how this code works?
>Thanks in advance
This is an example of what I might consider "poor commenting" :)
Why, and I emphasize *WHY*, don't people comment their damn code?
I have enough trouble trying to figure out my own code that I wrote last
year, let alone new code that I happen to find on the internet.
Fortunately, this is simple enough. It is LCD message code. Basically, it
calls one lookup table containing messages to output to the LCD, separated
by zeroes, and sends them to lines 1 and 2 of the display. There is no LCD
initialization here, nor are there any actual messages (among other things)
so this code wouldn't work in and of itself.
------------------------------------
>MnLoop clrf MessPt
> movlw 0x80 ; line 1
> call LCDins
The above code sets the message pointer MessPt to the beginning of the
message table, and sends 0x80 to the LCD as an instruction to move the
cursor to column 0 of the first line.
>Loop1 call TheText
> xorlw 0h
> btfsc STATUS,Z
> goto DoLine2
> call LCDout
> incf MessPt
> goto Loop1
The above code looks for a table with a label "TheText" and returns one
character at a time until a value of 0x00 is found at the end of the first
message.
>DoLine2 incf MessPt
> movlw 0xC0 ; line 2
> call LCDins
The above code does the same as the initial code, except positions the
cursor at column 0 of the second LCD line.
>Loop2 call TheText
> xorlw 0h
> btfsc STATUS,Z
> goto DoDelay
> call LCDout
> incf MessPt
> goto Loop2
The above code does the same as the previous code loop. Note that the
message pointer has been incremented at the DoLine2 label, advancing past
the first "0x00" found in the message table. This loop then calls the same
message table "TheText" and outputs each character to the LCD until the
second "0x00" is found in the table.
>DoDelay call BigDel ; wait
> goto MnLoop
Wait and return to do this entire thing again. Note that the display is not
cleared, so each message will simply overwrite the previous message.
--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
More... (looser matching)
- Last day of these posts
- In 2001
, 2002 only
- Today
- New search...