Discussion Forum

preset of a code-byte

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Lutz Pape
Posted
5-Jul-2001 12:36 GMT
Toolset
C51
New! preset of a code-byte
Hi,
I would like to preset a byte at a specific adress in the code memory with a specific value.
code char BYTE=0x55; //works, but adress not specified
code char BYTE _at_ 0xF000; //works, but value not specified
code char BYTE=0x55 _at_ 0xF000; //leads to Sytanx Error

How do I tell the Compiler to preset the byte in the code memory?

Thanks,
Lutz
Read-Only
Author
Andrew Neil
Posted
5-Jul-2001 13:12 GMT
Toolset
C51
New! RE: preset of a code-byte
The manual states two limitations of the _at_ keyword:
"1. Absolute variables cannot be initialized."

So you can't do it that way.

I'm sure this was discussed not so long ago - use the Forum Search (link in the left sidebar)

Get the Linker to fix the location?
Read-Only
Author
Andrew Neil
Posted
5-Jul-2001 14:14 GMT
Toolset
C51
New! RE: preset of a code-byte
searching the Forum was not so easy, as it refuses to search for "_at_"
Doh! :-(

Anyway, the Thread is, "Writing constant to ROM"
http://www.keil.com/forum/msgpage.asp?Offset=-1&MsgID=1197

Jon Ward suggested this link:
http://www.keil.com/support/docs/301.htm
Read-Only
Author
Lutz Pape
Posted
6-Jul-2001 08:14 GMT
Toolset
C51
New! RE: preset of a code-byte
Thank you very much for the answer. I wonder that the Keil-Compiler has so much
problems in combinig the _at_ directive and initialization. I think it's
a pretty complicate way to make the compiler generate assembler-code
like:
cseg
org 0F000H
foo: DB 0EEH

END

Funny: Keil's low-cost competitor 'Raisonance' allows such a syntax:
at 0xF000 code const char foo=0xEE;
and it works pretty fine.


Lutz

Next Thread | Thread List | Previous Thread Start a Thread | Settings