[HN Gopher] Handling Long Branches
       ___________________________________________________________________
        
       Handling Long Branches
        
       Author : ingve
       Score  : 27 points
       Date   : 2026-01-26 07:31 UTC (1 days ago)
        
 (HTM) web link (maskray.me)
 (TXT) w3m dump (maskray.me)
        
       | stevekemp wrote:
       | It was only a couple of years ago since I wrote an assembly
       | language program of my own and got hit by branching-limits on the
       | Z80 processor.
       | 
       | I did exactly the same things that were suggested in this
       | article, either inverted conditionals, or had a thunk -
       | essentially "jmp nextJump", where that jumped to the actual
       | location.
       | 
       | I sometimes spent a few hours shuffling code around to remove the
       | longer jumps and re-order code in groups closer together to save
       | individual bytes.
        
       | netule wrote:
       | It looks like the author has renamed their blog post, and thus
       | the link has changed: https://maskray.me/blog/2026-01-25-long-
       | branches-in-compiler...
        
         | zdimension wrote:
         | Related: https://www.w3.org/Provider/Style/URI
        
       | kccqzy wrote:
       | This is really useful! I only knew about -mcmodel during
       | compilation but I didn't know the linker would insert thunks for
       | faraway branches. I would've thought that the linker would simply
       | complain and ask you to recompile with a larger code model. Also
       | interesting that different linkers (or the same linker on
       | different architectures!) chose different thunk creation
       | algorithms.
        
       ___________________________________________________________________
       (page generated 2026-01-27 23:01 UTC)