CS280 Lab 3: LCD Scrolling Text Jonathan Dunder and Derek Bressler We both spent approximately three hours on this lab assignment. We programmed the microprocessor to scroll the text "Sixteen Characters" on the LCD screen repeatedly. The microprocessor also counts the length of the string in memory and sends this length to the LCD control algorithm. ; Hello World Demo ; Written by Dr. H. Welch, 3/18/2005 ; Updated by Dr. E. Durant, 3/20/2005 (latest tools, ; more documentation, 8.3 WBUG11 limit) ; $Id: hello.s,v 1.2 2005/03/21 06:11:27 durant Exp durant $ ; Assemble with : as -o hello.o hello.s ; Link with : ld -T ../fox11w.x -o hello.elf hello.o ; Convert to S19 : objcopy -O srec hello.elf hello.s19 ; Create a listing: objdump -d hello.elf > hello.rst ; DER - Modified to use lcdout.s, and relocate stack pointer to ; Buffalo friendly address. MAXLEN = 35 .section .page0 linelength: .short 1 ; = does not allocate memory; it is like a #define in C++ ;;;;;;;;;; Data (read-only, ROMable) ;;;;;;;;;; .section .rodata ; read-only data, this is put in the text section, after executable code ; Describe strings to display. The trailing NULs are not needed by ; LCD_LILNE?, but they might be useful for calculating the string length ; at runtime. line1: .asciz "Sixteen charactersSixteen character" LINE1LEN = 35 ; Note: OUTSTRG00 (see buffalo.s) sends data back to the monitor (e.g., WBUG11) ; over the serial port. It might be useful for debugging. ;;;;;;;;;; Executable code, main entry point ;;;;;;;;;; .section .text .global _start ; exported entry point expected by GNU as _start: ; Set up string pointer and counter ldx #line1 ; pointer to string ldy #0 ; count of non-null characters ; Advance through string, calculating length, and minding MAXLEN. 1: tst 0,x ; Have we found a null in the string? beq 2f ; If so, we're almost done -- go to final code (2f = forward to 2). iny ; Count the character we just saw. ;cpy MAXLEN ; Have we reached the maximum length? ;beq 2f ; If so, we're almost done -- go to final code. inx ; Otherwise, point to the next character... bra 1b ; ...and repeat. (1b = backward to 1) ; Finally, store the length in memory and come to a stop (sort of). 2: sty linelength bra 3f 3: ldy #18 jsr LCD_INI ; Initialize the display ldx #line1 lds #0x8fff ; Initialize stack pointer - Buffalo friendly 4: ldab #linelength jsr LCD_LINE1 ; LCD_LINE1 destroys D (A:B) and X. Y is untouched. bsr wait inx dey bne 4b beq 3b bra . .section .text ; subroutine wait - waits 250 ms - modifies nothing wait: psha ; save A tpa ; save condition codes psha ; " pshx ; save X ldx #250 ; wait 250 milliseconds 1: bsr wait1ms ; local label dex bne 1b pulx ; restore X pula ; restore condition codes tap ; " pula ; restore a rts wait1ms:psha ; 1 ms wait tpa psha pshx ldx #200 2: dex nop nop bne 2b pulx pula tap pula rts ; Get LCD routines ; include after code so it doesn;t assemble at beginning of ; code segment .include "lcdout.s"