Page 1 of 1
Copying es:di to a descriptor
Posted: Mon Aug 26, 2002 10:16 pm
by Matt
I have some source code that requires me to copy es:di to a descriptor (in pmode) after calling a VESA function in real mode, but I get a 'invalid combination of [something] and op-code' when I try to do this:
mov [my_vesa_selector],[es:di]
I've tried this with different combinations of [ ]'s but nothing seems to work! my code actually looks a bit more like this:
;in real mode
mov ax, 0x4f0a
mov bx, 0
int 10h
;Switch to protected mode
;create the vesa_descriptor with john fine's desc macro
mov [vesa_descriptor],[es:di] ;I get the error Here
[glow=red,2,300]Thanks for helping
[/glow]
Btw, this is in my boodloader. It sets up my GTD too so I know nothing is wrong with the vesa_descriptor
Re:Copying es:di to a descriptor
Posted: Mon Aug 26, 2002 11:00 pm
by PlayOS
Why dont you just convert [es:di] to a real address (es * 0x10 + di) and then use the data at the address, rather than copying it.
; convert to a physical address
mov ebx, es ; desired segment
shl ebx, 4 ; multiply by 16
add ebx, di ; add offset
; ebx = ptr to the data
if [es:di] holds a selector value then use an intermediate register first like this
mov ax, word [es:di]
mov word [my_vesa_selector], ax
Re:Copying es:di to a descriptor
Posted: Mon Aug 26, 2002 11:44 pm
by PlayOS
I had a look at the VESA docs and I am assuming you want to copy the PMode Interface into your selector.
You have two ways to do it, you can either create a new descriptor and use (es * 0x10 + di) as its base address, then its selector will be already filled with that code, all you will have to do then is set the descriptor limit to the same value as cx because cx has the size in bytes after the call to int 0x10, AX=0x4f0a.
The other way is to create the descriptor as above and select it into fs we will call it FS_SEL, then copy byte for byte to your vesa selector like this
xor ebx, ebx
loop:
mov al, byte [FS_SEL:ebx] ; get a byte from buffer
mov byte [VESA_SEL:ebx], al ; save the byte to vesa_selector
dec cx ; decrement cx
inc ebx ; increment the offset (use add ebx, 2) for word copies
cmp cx, -1 ; cx = -1 after the last byte is copied
je loop ; keep on going until cx = -1
This assumes that in your vesa_selector you will be starting at offset 0.
This is not the fastest routine but it should work, you could increase the size of each move to gain speed but the size of the block might not be an even number of words or dwords.
I hope this helps, I am still a learner as well. I hope I have no just confused you.
Re:Copying es:di to a descriptor
Posted: Tue Aug 27, 2002 6:08 pm
by Matt
I am still a learner as well. I hope I have no just confused you.
I'm an (almost) complete newbie to ASM and os development, but I think that was pretty easy to understand
Thanks
Re:Copying es:di to a descriptor
Posted: Wed Aug 28, 2002 2:01 am
by Pype.Clicker
Matt wrote:
I have some source code that requires me to copy es:di to a descriptor (in pmode) after calling a VESA function in real mode, but I get a 'invalid combination of [something] and op-code' when I try to do this:
mov [my_vesa_selector],[es:di]
I've tried this with different combinations of [ ]'s but nothing seems to work!
the reason why you get an error is that you can't have 2 memory references in the same move.
you should write this as
mov eax,[es:di]
mov [my_vesa_selector],eax
Re:Copying es:di to a descriptor
Posted: Wed Aug 28, 2002 9:33 am
by Matt
Sweet, it assembles now :]