Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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


List of 23 messages in thread
TopicAuthorDate
SDCC assembler Questions            01/01/70 00:00      
   :: or .globl            01/01/70 00:00      
   do you mean .globl directive?l            01/01/70 00:00      
   so far, so good now how specify xdata            01/01/70 00:00      
      what are you trying to do            01/01/70 00:00      
   is there a current SDCC documentation?            01/01/70 00:00      
      at least UserGuide from Googel :-)            01/01/70 00:00      
         unsigned char _far _at(0x700) buf[0x100]            01/01/70 00:00      
         without a word about the assembler            01/01/70 00:00      
      documentation            01/01/70 00:00      
         sample in pseudocode            01/01/70 00:00      
            okay and how do you want to use it?            01/01/70 00:00      
               a simple example            01/01/70 00:00      
                  thanks for the examples and ...            01/01/70 00:00      
      current SDCC documentation            01/01/70 00:00      
         evidently XDATA assembler is not 'current'            01/01/70 00:00      
            my installation has asxxhtm.html in doc/as            01/01/70 00:00      
               well, you get what you pay for and            01/01/70 00:00      
                  SDCC is free after all            01/01/70 00:00      
                     They frequently claim it in the negative            01/01/70 00:00      
                     from my first post "            01/01/70 00:00      
                        asxxxx tools            01/01/70 00:00      
                           as it turned out ...            01/01/70 00:00      

Back to Subject List