[z80-coff-ld] how can I use ld for creating an exe from z80-coff-as ?

jseb gmane2010@finiderire.com
Tue Feb 21 21:10:00 GMT 2012


Hello,

I've compiled this source file, using z80-coff-as.

~/z80-coff-as -als hello_world.asm -o hello_world.out

GAS LISTING hello_world.asm                     page 1


    1 0000 FE             db $fe
    2 0001 00C0 1AC0      dw debut,fin,debut
    2      00C0
    3
    4 0007 0000 0000      ORG $C000
    4      0000 0000
    4      0000 0000
    4      0000 0000
    4      0000 0000
    5
    6                    debut:
    7 c000 210D C0        LD HL,LABEL
    8 c003 7E            AFF: LD A,(HL)
    9 c004 23             INC HL
   10 c005 A7             AND A
   11 c006 C8             RET Z
   12 c007 CDA2 00        CALL $A2 ; HFDA4 ;CHPUT
   13 c00a 18F7           JR AFF
   14 c00c C9             RET
   15 c00d 5465 7374     LABEL: DEFB "Test chput",13,10,0
   15      2063 6870
   15      7574 0D0A
   15      00
   16                    fin:
   17                     END

GAS LISTING hello_world.asm                     page 2


DEFINED SYMBOLS
                             *ABS*:0000000000000000 fake
      hello_world.asm:6      .text:000000000000c000 debut
      hello_world.asm:16     .text:000000000000c01a fin
      hello_world.asm:15     .text:000000000000c00d LABEL
      hello_world.asm:8      .text:000000000000c003 AFF

NO UNDEFINED SYMBOLS


So, it gives me a COFF object files, and i don't want all those 
sections, as it's for using inside an 8 bit emulator (target is MSX 
machine).
I had success using «coff-z80-objcopy» with binary output, but i'd 
rather like using the linker instead.

I tried with:

~/test$ z80-coff-ld.bfd hello_world.out -o hello_world.msx

~/test$ hexdump hello_world.msx -C
00000000  fe 00 c1 1b c1 00 c1 00  00 00 00 00 00 00 00 00
   |................|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
   |................|
*
0000c000  21 0d c1 7e 23 a7 c8 cd  a2 00 18 f7 c9 48 65 6c
   |!..~#........Hel|
0000c010  6c 6f 20 57 6f 72 6c 64  0d 0a 00
   |lo World...|

As you can see, the first bytes show that the origin is now 0xc100 , 
instead of 0xc000.
I guess it's because ld adds 0x100h (old .com startup) to my .org setting.
Another problem is i don't want all those fillers, between stub (the 
first seven bytes) and the start of my code section (at 0xc000).

I want to get this instead:
00000000  fe 00 c0 1b c0 00 c0 21  0d c0 7e 23 a7 c8 cd a2
   |.......!..~#....|
00000010  00 18 f7 c9 48 65 6c 6c  6f 20 57 6f 72 6c 64 0d
   |....Hello World.|
00000020  0a 00

I tried to set up a little ld script, for using with «-T» flag of ld, 
but all i got is the return of «COFF» sections…
SECTIONS
      {
        . = 0xC000;
        .text : { *(.text) }
      }


I've made extensive search on the web, on this list, and on dedicated 
emulators list, but didn't find anything about this problem.
If someone can helpÂ… thank you.



More information about the Binutils mailing list