View Single Post
Old 04 October 2021, 10:06   #33
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,577
Quote:
Originally Posted by Thomas Richter View Post
Splitting it would force you to think about clear modules, and responsibilities of the sources. 30000 lines in one file is just... too large. Probably by two magnitudes too large for a single file.
I like it that way because I only have to open one file and know what I want to work on is in there. In this project I often have to work on various parts at the same time, and since I am doing it on an A1200 connected to a TV I don't have a lot of screen space to show multiple files.

However I am open to different ways of doing things, so I will try splitting it up to see if that works better.

Quote:
ViNCEd is all PC-relative with branches between modules, and of course that works. If the distances get too large, the linker will insert ALVs for you (trampoline code).
I admit I didn't realize this was possible in assembler (never tried merging sections before). I found out that ProAsm can generate XREFs automatically, which saves a bit of typing (still have to put the XDEFs in by hand of course).

I did a small test using blink and it did indeed add 'trampoline' code, and also relocated pc-relative data references. However it seems I need a better linker because it also tried to trampoline data references - and failed spectacularly.

Code:
; -- blink tries to 'trampoline' a pc-relative data reference --

   Section 0,CODE

r000000:
   lea     i00000c(PC),A0  ; <-- supposed to be lea r008018(pc),a0
   bsr     r000012
   rts

   align.l
i00000c:
   jmp     r008018         ; <-- but was 'trampolined' with a jmp!
r000012:
   jmp     r00801a         ; <--- this one is OK

; -- second object file merged here --

w000018:
   ds.b    32768

r008018:                   ; oops! not code!
   dc.w    $1234
r00801a:
   lea     w000018,A0
   rts

   align.l

   end
blink also caused a few enforcer hits during operation, even when not 'stressed'. Not sure that I can trust it.

'Trampolining' branches only works if there is less than 32k between the branch and the end of the section. This means I will have to split my code up into sections with less than 32k of code in them to ensure the 'trampoline' works. Alternatively I could just change long branches into jmps like I do now, which produces tighter and faster code.

Quote:
Side remark:ARexx is just like that, one big pile of mess, assembled with one file that includes a lot of the other sources, with modules that have just numbers, not telling names. Needless to say, it is incredibly hard to maintain this pile of code. Probably that's Bill's revenge against CBM for not having paid him...
Or perhaps he just prefers to code that way.

Splitting code up into separate object files can also be messy. Some Amiga programs that (I presume) were coded by people unfamiliar with advanced linking techniques have a very large number of hunks, sometimes with only a few bytes or nothing in them. AmigaBASIC has 81 hunks. F18-Interceptor has 185 hunks! The source code for that must be 'interesting'.
Bruce Abbott is offline  
 
Page generated in 0.09307 seconds with 11 queries