EmbeddedRelated.com
Forums

declaring a variable and a string for 68HC12

Started by Lerzan Celikkanat April 5, 2005

Below code (written for Motorola 68HC12) displays the alphabet on an lcd
screen. How can I modify this code so that it can display a welcome message
for 5 sec.s and then print out a variable called "price" .

In other words how do i declare a string and a variable for hc12?
if it were hc05 it would have been something like
ORG $50
msg DB "Welcome./"
price DB "$00.00"

but DB wont work in hc12. what's the way of doing this in hc12? ;**********************************************
;* LCD display
;* this code initilizes the LCD module and
;* displays the alphabet.
;*
;**********************************************

PORTT EQU $0240
PORTM EQU $0250

DDRT EQU $0242
DDRM EQU $0252

ORG $4000
; set port data patterns and directions
STACK LDS #$4000
TRYLCD LDAA #$FF
STAA DDRM
STAA DDRT
LDAA #$00
STAA PORTM

; LCD display peripheral needs to be initilized
LDAA #$01
JSR WCTRL ; clear
LDAA #$01
JSR WCTRL ; clear
LDAA #$02
JSR WCTRL
LDAA #$38
JSR WCTRL
LDAA #$0C
JSR WCTRL
LDAA #$06
JSR WCTRL

LDAA #'a' ; ascii a
DLP JSR WDAT ; display a character
INCA ; to next character
CMPA #'z' ; ascii t
BNE DLP ; loop till t
HERE BRA HERE ; Stop ;*************************************************************

WCTRL STAA PORTT
PSHA
BSET PORTM,%00000010
NOP
NOP
NOP
NOP
BCLR PORTM,%00000010
CLRA
CTRDLY2 PSHA
CLRA
CTRDLY1 DECA
BNE CTRDLY1
PULA
DECA
BNE CTRDLY2
PULA
RTS ;************************************************************** WDAT STAA PORTT
PSHA
BSET PORTM,%00000100
BSET PORTM,%00000010
NOP
NOP
NOP
NOP
BCLR PORTM,%00000010
BCLR PORTM,%00000100
CLRA
DATDLY1 DECA
BNE DATDLY1
PULA
RTS

ORG $FFFE ;reset vector
FCB $40
FCB $0 *****************************************************************************
Lerzan Celikkanat
Syracuse University

College of Engineering
& Computer Science


Why don't you program this in C?

---------------------------------


There are hc12 assemblers with 'motorola' syntax and some with a sort of
'unix' syntax, but they all have a way of declaring characters... try .db or fcc
or fcb or (God forbid) see if that particular assembler has a help file


At 01:34 PM 4/5/05, you wrote:
>but DB wont work in hc12. what's the way of doing this in hc12?

DB is a compiler directive, not an instruction. They are all different,
you'll have to look in the assembler/compiler documentation.

Gary Olmstead
Toucan Technology
Ventura CA
www.toucantechnology.com


> but DB wont work in hc12. what's the way of doing this in hc12?

The answer lurks in the last three lines of the code you posted, which
initialize the reset vector. For convenience, I'll quote them here:

> ORG $FFFE ;reset vector
> FCB $40
> FCB $0

I'd strongly recommend reading the assembler manual or help file to see
how these directives are processed. There is almost certainly a concise
syntax for strings, which you will want to use.

Stephen

--
Stephen Trier
Technical Development Lab
Cleveland FES Center
sct@sct@...




> ORG $50
> msg DB "Welcome./"
> price DB "$00.00"
>
> but DB wont work in hc12. what's the way of doing this in hc12?


msg dc.b 'Welcome./'
price dc.b '$00.00'

is the syntax I used for MiniIDE, MCUez and CW.
--- In 68HC12@68HC..., "Lerzan Celikkanat" <lerzan83@h...> wrote:
>
> Below code (written for Motorola 68HC12) displays the alphabet on an
lcd
> screen. How can I modify this code so that it can display a welcome
message
> for 5 sec.s and then print out a variable called "price" .
>
> In other words how do i declare a string and a variable for hc12?
> if it were hc05 it would have been something like
> ORG $50
> msg DB "Welcome./"
> price DB "$00.00"
>
> but DB wont work in hc12. what's the way of doing this in hc12?