Reputation: 111
Hey so I'm trying to get into lower level systems programming in 64 bit arm, and I'm trying to branch forward 64 bytes, specifically to skip the Image header. I noticed that under arm64, PC is no longer an accessible register. How would I branch forward 64 bytes relative to the current position in arm64 assembly? I need it to fit in two or less instructions (code0 and code1). Thanks
Upvotes: 1
Views: 1299
Reputation: 71536
something like this (give or take a word/byte to fine tune it)
b hello
.word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0
hello:
Disassembly of section .text:
0000000000000000 <hello-0x84>:
0: 14000021 b 84 <hello>
...
which then leads to
b hello
.word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0
hello:
.inst 0x14000021
Disassembly of section .text:
0000000000000000 <hello-0x84>:
0: 14000021 b 84 <hello>
...
0000000000000084 <hello>:
84: 14000021 b 108 <hello+0x84>
okay so I cant count to 64 correctly...But you get the idea, I think I meant to use .byte not .word...
You either use labels or if you want to have a fixed offset use the machine code.
Some assemblers (assembly is defined by the assembler not the target) might support something like this:
hello:
b .+64
Disassembly of section .text:
0000000000000000 <hello>:
0: 14000010 b 40 <hello+0x40>
But I would expect that to be extremely assembler (assembly language) specific and not port across aarch64 assemblers. (where some flavor of .word 0x14000010 would port)
Upvotes: 4