by ryao · 1y ago · 0 comments
It's also possible to detect which mode the CPU is in:
bits 16
mov ax,start16 ;may load EAX instead,
jmp ax ;skipping this 2-byte instruction
bits 32
dec eax ;REX prefix in long mode,
mov eax,start32 ;may load RAX,
jmp eax ;skipping these 4 bytes
nop
nop
bits 64
jmp start64
You can even be compatible with CP/M-80 by putting this at the start: add bx,start8 ;8080: ADD C, JMP start8
nop ;immediate may be 16 or 32 bits
nop