Code: Select all
......
jump16 macro selector,offsetv
db 66h
db 0eah ;jmp
dw offsetv ;2 bytes offset address
dw selector
endm
You should explain that that's a prefixed far jump instruction. Is there some reason why you need to write this in a mixture of direct machine code and assembler? Is there some reason why you need a macro to do a simple far jump?
Code: Select all
....
cseg1 segment use16
assume cs:cseg1
start:
...
cli
;
mov eax,cr0
or eax,1
mov cr0,eax
.....
Do these lines of dots represent missing code that you've edited out? I'm guessing that they must do because I can't imagine that you've tried to switch to protected mode without setting up a GDT.
Again there must be code missing, because it looks as if it then runs straight on into this, but clearly it can't.
Code: Select all
cseg1 ends
;
cseg3 segment use32
assume cs:cseg3
I don't know what that does, but I'm sure you know more about assembler than I do.
Code: Select all
spm32:
mov eax,cr0
and eax,0fffffffeh
mov cr0,eax
;Return to code
jump16 <seg toreal>,<offset toreal>
;
cseg3 ends
That appears to switch to real mode and then try to jump to the stuff further up via your macro. I assume the macro posts a far jump instruction into your code at this point. I don't think it's possible to jump straight back from 32-bit protected mode into real mode without going through 16-bit protected mode along the way. So far as I'm aware, you have to do a far jump into a 16-bit protected mode segment first, then switch to real mode, then do another far jump to load CS with a real mode value, and neither of those far jumps will take a prefix.