I use Dallas 390 and I want to map the device I/O into RAM which can be accessed by Dallas 390.I have the following solution: 1. Using XSEG in Ax51 as the following example
XSEG AT 08000h IO_PORT: DS 1
//head file: head.h extern unsigned char IO_PORT; //source file:source.c #include "head.h" ... IO_PORT = 0x01; ...
XSEG AT 40BC00h IO_PORT: DS 1
//file IO.c unsigned char far IO_PORT _at_ 0x40BC00; //head file:head.h extern unsigned char far IO_PORT; //using IO_PORT in sourc.c #include "head.h" ... IO_PORT = 0x01; ...
#define IO_PORT 0x8000 unsigned int addr; XBYTE[IO_PORT] = 0x01; addr = 0x8000; XBYTE[addr] = 0x01;//segment number + (addr) FVAR(unsigned char,0x40BC00) = 0x01;
unsigned char IO_PORT _at_ 0x8000; ... IO_PORT = 0x01 ...
Your core problem, I think, is that you shouldn't be using XSEG for this. XSEG is for classic '51s, but doesn't really match the capabilities of the Dallas 390. Use a SEGMENT and an RSEG directive, instead. Either that, or you simply forgot to use AX51 instead of A51, or didn't configure it for '390 contiguous mode. You'll probably see the C compiler do the same, if you have it generate ASM source code from your C _at_ definition. Using XSEG would be equivalent to omitting the far keyword in your C version --- that'll fail for the 0x40zzzz address range, too.