??? 05/14/10 21:30 Modified: 05/14/10 21:31 Read: times |
#175920 - a simple example Responding to: ???'s previous message |
First, as said above, I observed, how does SDCC's asm output look like (I roughly understand it). Then I read a bit about .obj and came up with the following (I was afraid to use ".asm" extension, in case sdcc makes some "magic" with "well known extensions"):
.module b .optsdcc -mmcs51 --model-small .globl _z .globl _z1 .area XABS (ABS,XDATA) .org 0x0800 _z:: .ds 10 _z1:: .ds 20 To try to "integrate" it into C I modified the first c program to the following: #include <stdint.h> __xdata __at 0x200 uint8_t a[10]; __xdata uint8_t b[10]; extern __xdata uint8_t z[10]; extern __xdata uint8_t z1[20]; void main(void) { b[0] = z[0]; a[0] = z1[0]; } I then observed how SDCC calls the assembler, by using the -V switch while invoking SDCC on a.c. I used that to assemble b.aa into b.rel; then I compiled a.c into a.rel, then linked them both together (the compilation of multiple c sources and linking them together is described in the manual and I think we have already discussed it here - the .rel object containing main() must come first) (I used --debug so to obtain the after-linking-"fixed" .rst listings): sdas8051 -plosgffwz b.rel b.aa sdcc -c a.c sdcc a.rel b.rel --debug And the relevant part of a.rst now is: 138 ; a.c:9: b[0] = z[0]; 0064 90 08 00 139 mov dptr,#_z 0067 E0 140 movx a,@dptr 0068 90 00 00 141 mov dptr,#_b 006B F0 142 movx @dptr,a 143 ; a.c:10: a[0] = z1[0]; 006C 90 08 0A 144 mov dptr,#_z1 006F E0 145 movx a,@dptr 0070 90 02 00 146 mov dptr,#_a 0073 F0 147 movx @dptr,a 0074 22 148 ret which is IMHO completely OK. I believe this fulfills your above need. Please feel free to ask. Jan |