1

Porting jonesforth to 64 bit macos catalina, I have this x86 instruction

mov $cold_start,%esi    // Initialise interpreter.  

I want to translate. I'd like to use

mov $cold_start,%rsi    // Initialise interpreter.  

but of course, I get an error

jonesforth.S:1404:2: error: 32-bit absolute addressing is not supported in 64-bit mode

(this is using the apple assembler, comes with xcode).

My first attempt was

mov $cold_start(%rip),%rsi    // Initialise interpreter.  

but the assembler also does not recognize it either

jonesforth.S:572:17: error: unexpected token in argument list

In sheer desparation, I tried

mov cold_start(%rip),%rsi    // Initialise interpreter.  

which assembles but of course derefences the address.

So my question is

1) how to load an absolute address in x64 with the apple assembler (all addresses are a <10kiB apart). Any pointers to x64 programming on the Mac would be great. I have had small pickings looking around.

2) if it's impossible, how to run the gnu assembler on x64 on Catalina? I have not been able to invoke it, either.

Please don't recommend to switch to running in a docker image - yes I can do that but I want to use the out of the box MacBook software.

  • It might be using the GNU invention of `movabsq`. That's not position independent but gives you full 64 bits. If it's a label you can also do `lea cold_start(%rip), %rsi`. – Jester May 19 '20 at 17:44
  • Thanks, I just googled http://c9x.me/notes/2015-09-19.html and found the reference to movabsq. The lea looks great too. Thanks a ton! – Klapaucius Klapaucius May 19 '20 at 17:50
  • You don't want 10-byte `movabsq` for addresses. Only use a 64-bit mov-immediate for large constants that aren't addresses, like `mov $0x3333333333333333, %rcx` / `and %rcx, %rax`. (With large numeric constants, the assembler will pick the movabs encoding for you when you write it as `mov`.) – Peter Cordes May 19 '20 at 18:02

0 Answers0