In NASM, I can easily do it using label like this
times 510-($-$$) db 0
db 0x55, 0xaa
However, I can not use label in a GAS .rept
command, It is invalid
current:
.rept 510-current-_start
.byte 0
.endr
; Error occures `Error: bad or irreducible absolute expression`
I wonder what is a absolute expression(I saw it in a gas document), I think
510-current-_start
should be accepcted because the value of this is calculated while compiling.How can I elegantly put
0x55
and0xaa
in a right position?I found
.space
works but.rept
doesn't, why?
; It works
current:
.space 510-current-_start
; Error: bad or irreducible absolute expression
current:
.rept 510-current-_start
.byte 0
.endr
EDITED:
It does't work too(using parentheses), I think It might be a bug?
; Error: bad or irreducible absolute expression
current:
.rept 510-(current-_start)
.byte 0
.endr