View Single Post
Old 01 May 2024, 17:54   #1552
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,182
Quote:
Originally Posted by jotd View Post
I have a question: is there an equivalent of __LINE__ for current asm line number?

I'd like to set a register like

Code:
    move.l  #__LINE__,d0
in case of an error for instance

BTW I had a lot of issues with PC-relative LEA which weren't in the same unit. I got a warning when linking (using long... for ...) but the address was still PC relative and it read at the wrong location.

Great assembler no matter what. Using it for 15+ projects now.

The exact snippet you wrote does work as intended if you enable preprocessing and use the gcc frontend (i.e. not as, otherwise preprocess manually).


This happens automatically if the input file is called ".S" rather than ".s" (yes, bad convention on case-insensitive file systems). Alternatively you can add "-x assembler-with-cpp" on the command line.


Code:
/tmp$ cat test.S && m68k-amigaos-gcc -c test.S && m68k-amigaos-objdump -D test.o
        nop
        move.l #__LINE__,d0


test.o:     file format amiga


Disassembly of section .text:

00000000  .text:
   0:   4e71            nop
   2:   7002            moveq #2,d0
paraj is offline  
 
Page generated in 0.05801 seconds with 11 queries