Close

Writing string to LCD in ASM

A project log for Elevator Simulation

Final laboratory project for ECE2510 Intro to Microprocessors at Western Michigan University

nate-bowenNate Bowen 04/02/2016 at 05:070 Comments

To write a string to the LCD on the HCS12, I wrote the following bit of assembly:

;main bit of program running up here
;               ....  ........              
;               ....  ........
                LDX   #NEX_FLR        ;load X with string pointer
                LDY   #NEX_LEN        ;load Y with string length
                JSR   WRT_STRING      ;jump to WRT_STRING sub
                

WRT_STRING					
DISP		  
		LDAA  X               ;put the value at X in A
		JSR   DATWRT4         ;sub to write the character
		JSR   DELAY           ;required delay for LCD
		INX                   ;next letter in the string
		DBNE  Y, DISP         ;decrement string count and repeat
		RTS                   ;once string is all printed, return


NEX_LEN EQU     11                    ;string length
NEX_FLR FCB     'Next Floor '         ;string contents

Discussions