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
Copying es:di to a descriptor
Re:Copying es:di to a descriptor
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
; 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
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.
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
I'm an (almost) complete newbie to ASM and os development, but I think that was pretty easy to understandI am still a learner as well. I hope I have no just confused you.
Thanks
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Copying es:di to a descriptor
the reason why you get an error is that you can't have 2 memory references in the same move.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!
you should write this as
mov eax,[es:di]
mov [my_vesa_selector],eax