cancel
Showing results for 
Search instead for 
Did you mean: 

#Define a Word

brian4
Associate II
Posted on November 23, 2005 at 03:48

#Define a Word

5 REPLIES 5
brian4
Associate II
Posted on November 22, 2005 at 07:17

Is it possible to define a 16 Bit value as a constant

You can define a byte e.g. #define Name 255

Can you do the same but with a value of 03ff

or do I #define High Byte & #define Lo byte

Re Brian

omatza
Associate II
Posted on November 22, 2005 at 09:16

Hi Brian

I am not much of ST7 programmer, but I will try to contribute something here.

If you use assembly, maybe you can do this:

WORDS ; following addresses are 8 bit length

segment 'ram0'

.variable DS.W 0 ; reserve 16 bits

end

and you can use it like this (maybe)

ld A, variable

but A is 8 bit, so ...

In C I don't know.

yours

Oren

brian4
Associate II
Posted on November 22, 2005 at 09:19

Hi I am using assembler

But its a constant I want to define i.e. a label with a value

Re Brian

fggnrc
Associate II
Posted on November 22, 2005 at 10:36

Brian,

there are two ways to define a 16 bit constant (or label) for the assembler:

* by using the EQU directive (though somewhat deprecated...)

* by using the DC.W directive

see

http://www.st.com/stonline/books/pdf/docs/11392.pdf

Regards

EtaPhi

brian4
Associate II
Posted on November 22, 2005 at 10:58

Thanks I will have a read!