ASM: backwards positioning
Posted: Fri Aug 05, 2005 12:28 am
Now it's getting juicy.
I'm writing a bootsector, let's say for "educational" purposes. The following works (GAS syntax warning):
The idea is to merge the binary with an existing MBR, i.e. overwrite 0x1be - 0x1ff with the values of the MBR. Benefit is that I can conveniently address partition table entries in my code without having to juggle magic numbers and offsets.
So far, so good.
However, for aesthetic reasons (think hexdump), I would like my data not to be directly after the code, but rather directly in front of the partition table. So, after the last code line, I'd like to skip:
However, that doesn't work since it's somewhat recursive logic.
I know how I could make a workaround, but I'd like to know (since the purpose is educational anyhow): Is there a way to do such "backwards" positioning at all? Can I make my assembler to place some data in such a way that it ends at a known address?
Help appreciated.
I'm writing a bootsector, let's say for "educational" purposes. The following works (GAS syntax warning):
Code: Select all
.set PARTITION_TABLE_OFFSET, 0x1be
...some code here...
. = PARTITION_TABLE_OFFSET
_P1_Boot_Indicator: .byte 0
_P1_Start_Head: .byte 0
...
So far, so good.
However, for aesthetic reasons (think hexdump), I would like my data not to be directly after the code, but rather directly in front of the partition table. So, after the last code line, I'd like to skip:
Code: Select all
.set PARTITION_TABLE_OFFSET, 0x1be
...some code here...
. = PARTITION_TABLE_OFFSET - ( PARTITION_TABLE_OFFSET - DATA_START )
DATA_START:
MESSAGE: .asciz "Ready\n\r"
PANIC_MSG: .asciz "PANIC\n\r"
LBA_OVERRIDE: .byte 0
BOOTDEVICE: .byte 0xff
. = PARTITION_TABLE_OFFSET
_P1_Boot_Indicator: .byte 0
_P1_Start_Head: .byte 0
...
I know how I could make a workaround, but I'd like to know (since the purpose is educational anyhow): Is there a way to do such "backwards" positioning at all? Can I make my assembler to place some data in such a way that it ends at a known address?
Help appreciated.