NASM - The Netwide Assembler

NASM Forum => Other Discussion => Topic started by: romco on May 16, 2011, 12:29:52 PM

Title: aslink linker problem
Post by: romco on May 16, 2011, 12:29:52 PM
Dear all, you are experienced assembler folks, so I hope you might help me ? I could not find any other help or forum for asxxxx assembler and aslink linker. I am using chain SmallC compiler -> asxxxx (specifically as8085) to assemble and -> aslink to link it together with c run-time start-off asm file and i8080 run tim lib asm file and to produce intel hex output file for intel's 8080 processor. I am having problems with the last step - linking. My C run-time start-off code is at the right position 0000H in the HEX file but it is not corect, as there is also another line in the output HEX file with the same address containing different code. The 0000 address is there twice, once it contains the code from main and second occurence contains CRTSO code.
http://shop-pdp.kent.edu/ashtml/asls01.htm#Invoking (http://shop-pdp.kent.edu/ashtml/asls01.htm#Invoking)

I can't find a way to correctly link with aslink V5. Put it simple. I have three asm files for the linker. One of them contains startup code, with .area CRTSO (ABS) and .org 0H0000 directives. The other one contains run time library with directive .area C8080LIB (REL,CON) and the last one contans the main program with directive .area MAIN (REL,CON). The linker is invoked as aslink -l -o -s main main.rel c8080lib.rel crtso.rel and produces intel hex file. But I can see in the HEX code, that 0000 address is there twice, once it contains the code from main and second occurence contains CRTSO code. Correctly the main code should be concatenated after CRTSO section. Reading documentation does not help.
http://shop-pdp.kent.edu/ashtml/asxs02.htm#area (http://shop-pdp.kent.edu/ashtml/asxs02.htm#area) It states "Absolute sections are always overlayed with other sections of this program area." which is for me totally weird. It seems that I do not understand what absolute addressing means. I am absolutely confused why should absolute section be overlayed with other code, that does not make sence to me. Any help would be highly appreciated.
Title: Re: aslink linker problem
Post by: Frank Kotler on May 16, 2011, 02:59:41 PM
Never heard of the thing, but a google search reveals a question about it on this SF forum:

https://sourceforge.net/projects/sdcc/forums/forum/1864

You might find someone who knows the answer to your question there, if you don't get an answer here (Quite possible).

If you haven't, you might try the "-m" switch, and see if the .map file gives any clue what aslink thinks you're trying to do... Nasm's got a fairly new "-f ihx" output format, but I don't think that'll help you with 8080 code...

Sorry I can't be any more help...

Best,
Frank

Title: Re: aslink linker problem
Post by: romco on May 16, 2011, 06:22:17 PM
I found a solution. Invoking aslink with this param -b MAIN=crtsoend where crtsoend is a label at the end of CRTSO asm file, does the trick. The third c8080lib.asm is then concatenated after main somehow automatically :-)

 -b  area=expression
         (one definition per line in a linker command file.)
         This  specifies  an area base address where the expres-
         sion may contain constants and/or defined symbols  from
         the linked files.