This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

access data in bank 0

How do I access a variable in bank 0 ?

If I look in my .m51 file I see my var ISP_VERSION:

CODE 754EH 001AH UNIT ?CO?ISP_VERSION

Now I try to access this var from a different image in a different bank using C code:

ispversion = 0x754E;

sprintf(SendString,"\r\nISP version %s",ispversion );

THIS DOES NOT WORK IT SEEMS!!!

This code is part of my main() function. I see in the .m51 file of this image:

CODE 011DH 0BCAH UNIT ?PR?MAIN?MAIN

But I do not really understand in which bank the main functionis located. I see in my .m51 file also (if relevant):

TYPE BASE LENGTH RELOCATION SEGMENT NAME
-----------------------------------------------------
* * * * * * * D A T A M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
REG 0008H 0008H ABSOLUTE "REG BANK 1"
REG 0010H 0008H ABSOLUTE "REG BANK 2"

I also tried this C code but it did not work as well:

unsigned char code *ispversion;

ispversion = (unsigned char code*)0x754E;

sprintf(SendString,"\r\nISP version %s",ispversion );

you see: I am not a banking expert (yet)!

Parents
  • "you see: I am not a banking expert (yet)!"
    You are also not a C expert ;)

    Note that 0x754E is a number.

    But when you print with %s you are trying to print a text string not a number.

    The normal C string to print a 4-digit wide hexadecimal number is %04x (or %04X if you want capital letters).

Reply
  • "you see: I am not a banking expert (yet)!"
    You are also not a C expert ;)

    Note that 0x754E is a number.

    But when you print with %s you are trying to print a text string not a number.

    The normal C string to print a 4-digit wide hexadecimal number is %04x (or %04X if you want capital letters).

Children