C– – Efficiency

Descriptions of files that are also in Project 2 have been omitted.

[lcd]

Directory holding files for writing to an LCD screen.

lcd.asm

Routines for writing to an LCD screen.

lcd.irx

Mnemonics used by lcd.asm.

lcd_ram.irx

Allocates RAM for lcd.asm.

The only changes to the assembly are in mainasm.asm and in cmm1.asm. In mainasm.asm, two calls are made to setup and initialize the lcd. To allow this, the labels for the routines were declared external.

external lcd_setio external lcd_init

In _goasm, they are then called to initialize the LCD before it is used.

;set up the LCD call lcd_setio call lcd_init

In cmm1.asm, simple routines for writing characters and numbers were added, along with routines to bring the cursor to the beginning of the first and second row.

_writeNum

mov a0, *r7 – 2 call lcd_wrbcd2 ret

_writeCharacter mov a0, *r7 – 2 call lcdwchr ret

_rowZero

call lcd_row0 ret

_rowOne

call lcd_row1 ret

_writeNum and _writeCharacter get a value to write from the stack and then call routines in lcd.asm. _rowZero and _rowOne simply call routines in lcd.asm.

main.cmm has been modified by the addition of a function, showTime().

/************************************************

/Display the time on the LCD

************************************************/

cmm_func showTime(){ int temp; rowZero(); writeNum(time[WIDTH*0+0]); //hours writeCharacter(’:’); writeNum(time[WIDTH*0+1]); //minutes

5-54

Page 350
Image 350
Texas Instruments MSP50C6xx manual External lcdsetio external lcdinit