writing a message for a multi character LCD
2005-02-15 by Eric
Yahoo Groups archive
Index last updated: 2026-04-28 22:41 UTC
Thread
2005-02-15 by Eric
Hi group How can you write a assembly function to put messages on a LCD without doing multiple ldi r16,0x61 ; 'a' to lcd call putc ; send character to LCD ldi r16,0x62 ; 'b' to lcd call putc ; send character to LCD ldi r16,0x63 ; 'c' to LCD call putc ; send character to LCD From Eric
2005-02-15 by Richard Reeves
> How can you write a assembly function to put messages on a LCD without
> doing multiple
>
>
> ldi r16,0x61 ; 'a' to lcd
> call putc ; send character to LCD
> ldi r16,0x62 ; 'b' to lcd
> call putc ; send character to LCD
> ldi r16,0x63 ; 'c' to LCD
> call putc ; send character to LCD
The way I do it is to write the string like this at the end of the code:
message: .db "This is a message",$ff
Then do this:
mess:ldi zl,low(message*2) ;load base address of string
ldi zh,high(message*2);load base address of string
loop:lpm r16,z+ ;Load character from address in z to r16, inc z
cpi r16,$ff ;Check for string terminator character
breq exit ;If equal quit
rcall wrt_d ;If not equal, display character and loop
rjmp loop
exit:ret
Richard
--
Na vratima raja, ja savijam krila...
http://www.van-gogh.co.yu2005-02-15 by Eric
Thank you Richard The program works great only had to change "wrt_db" to "putc" . I thought there must be some "tidy" way of doing it, From Eric
----- Original Message -----
From: "Richard Reeves" <r_reeves@blueyonder.co.uk>
To: <AVR-Chat@yahoogroups.com>
Sent: Wednesday, February 16, 2005 4:20 AM
Subject: Re: [AVR-Chat] writing a message for a multi character LCD
> How can you write a assembly function to put messages on a LCD without
> doing multiple
>
>
> ldi r16,0x61 ; 'a' to lcd
> call putc ; send character to LCD
> ldi r16,0x62 ; 'b' to lcd
> call putc ; send character to LCD
> ldi r16,0x63 ; 'c' to LCD
> call putc ; send character to LCD
The way I do it is to write the string like this at the end of the code:
message: .db "This is a message",$ff
Then do this:
mess:ldi zl,low(message*2) ;load base address of string
ldi zh,high(message*2);load base address of string
loop:lpm r16,z+ ;Load character from address in z to r16, inc z
cpi r16,$ff ;Check for string terminator character
breq exit ;If equal quit
rcall c ;If not equal, display character and loop
rjmp loop
exit:ret
Richard
--
Na vratima raja, ja savijam krila...
http://www.van-gogh.co.yu
Yahoo! Groups Links2005-02-16 by Eric
Hi All Just to rap this up, were did I go wrong? is all the help from Richard described in a text book or a AVR tutorial on the AVR Studio? The help I got from Richard uses ".DB" I notice it is listed in "Assembler directives" along with .CSEG .DEF .ENDMICRO .ESEG .EQU .INCLUDE .MACRO .ORG in chapter "Annex" pages 41 to 52 from Avr-tutorial from the web site of www.avr-asm-tutorial.net I must go and buy that book someone recommended (when I get enough money together) From Eric
----- Original Message -----
From: "Eric" <erichards@clear.net.nz>
To: <AVR-Chat@yahoogroups.com>
Sent: Wednesday, February 16, 2005 7:06 AM
Subject: Re: [AVR-Chat] writing a message for a multi character LCD
Thank you Richard
The program works great only had to change "wrt_db" to "putc" .
I thought there must be some "tidy" way of doing it,
From Eric
----- Original Message -----
From: "Richard Reeves" <r_reeves@blueyonder.co.uk>
To: <AVR-Chat@yahoogroups.com>
Sent: Wednesday, February 16, 2005 4:20 AM
Subject: Re: [AVR-Chat] writing a message for a multi character LCD
> How can you write a assembly function to put messages on a LCD without
> doing multiple
>
>
> ldi r16,0x61 ; 'a' to lcd
> call putc ; send character to LCD
> ldi r16,0x62 ; 'b' to lcd
> call putc ; send character to LCD
> ldi r16,0x63 ; 'c' to LCD
> call putc ; send character to LCD
The way I do it is to write the string like this at the end of the code:
message: .db "This is a message",$ff
Then do this:
mess:ldi zl,low(message*2) ;load base address of string
ldi zh,high(message*2);load base address of string
loop:lpm r16,z+ ;Load character from address in z to r16, inc z
cpi r16,$ff ;Check for string terminator character
breq exit ;If equal quit
rcall c ;If not equal, display character and loop
rjmp loop
exit:ret
Richard
--
Na vratima raja, ja savijam krila...
http://www.van-gogh.co.yu
Yahoo! Groups Links
Yahoo! Groups Links2005-02-16 by John Samperi
At 04:55 PM 16/02/2005, you wrote:
>Just to rap this up, were did I go wrong? is all the help from Richard
>described in a text book or a AVR
>tutorial on the AVR Studio?
>
>The help I got from Richard uses ".DB" I notice it is listed in "Assembler
>directives" along with
The .DB directive is not just AVR specific. Most assembler would use
something like it. So you can just read up any assembler book.
Of course it would help to read something slanted towards the
AVR to keep things simpler. If you can progarm in assembler for
any processor you can quickly switch to the AVR assembler and the
Studio environment.
Regards
John Samperi
******************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495 Fax (02) 9674-8745
Email: samperi@ampertronics.com.au
Website http://www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
******************************************************