Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Reading from flash in Assembly

2004-12-04 by John Samperi

At 06:48 PM 3/12/04 -0500, you wrote:

OK this is what I do to get the data from a character generator
look up table (an array of 224 rows x 7 bytes wide).

;r16 has the character we want to get the data for 0x20-0xff
good_char:
	subi	r16,' '	;Multiplier LSB		(this just deducts 32 (0x20) from the number)
	clr	r17	;Multiplier MSB		(as there is no data for char 0-31 or control chars)

	ldi	r18,7	;Multiplicand LSB, 7 bytes each char
	clr	r19	;Multiplicand MSB	
	rcall	mpy16u	;Find offset in CHAR_GEN table	
			;of first row results in r18 and r19

	push	zl	;push z as this routine happens during ints
	push	zh

	clr	zh
	mov	zl,rownum 	;Load z with row_num
	add	zl,r18		;Add offset results
	adc	zh,r19
	ldi	r16,low(CHAR_GEN*2)
	ldi	r17,high(CHAR_GEN*2)

	add	zl,r16	;Add char gen start address
	adc	zh,r17

	lpm		;Go and get CG char into r0

	pop	zh	;restore z
	pop	zl
	ret

As you can see it's a LOT longer that what you have but it has been working
for many years, if anyone can shorten it I would be grateful :-))

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
******************************************************

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.