Copying data from memory to memory...
Posted: Wed Jul 04, 2007 8:06 am
Hello,
I search for a answer for my question:
I am copying data from one address, e.g. 0xF000:0xFFF5, to [es:CopyPointer] (I don't know the exact value of CopyPointer's IP, so I am using this syntax). In FASM, I can't just
I must assign the first hexadecimal number to some register, like CS, DS, ES, etc. So it looks like this:
And I must copy data from 0xF000:0xFFF5 (length: 8 - one dword) to the mentioned address es:CopyPointer, using this code:
but this wouldn't work at all, or, when ...
(you've guessed right, this is text data)
... this will display garbage or nothing at all.
NOTE: This code is in the first lines of my OS, so it's using real mode segmentation. After this and other things, it will jump into pmode.
Can you please tell me what the hell I'm doing wrong?
Regards inflater.
I search for a answer for my question:
I am copying data from one address, e.g. 0xF000:0xFFF5, to [es:CopyPointer] (I don't know the exact value of CopyPointer's IP, so I am using this syntax). In FASM, I can't just
Code: Select all
mov si,[0xF000:0xFFF5]
Code: Select all
mov ax,0xF000
mov ds,ax
mov si,[ds:0xFFF5]
Code: Select all
push es
push ds
mov ax,ds ;the pointer "CopyPointer" is located in the
mov es,ax ;include files of my OS at the very *end* to prevent
mov ax,0xF000 ;memory overwriting - so let DS=ES
mov ds,ax
mov si,[ds:0xFFF5]
mov cx,8 ;length
mov di,CopyPointer ;MOVSB is always as DI taking the ES seg register
rep movsb ;REP MOVSB instead of MOVSD, for safety I think
pop ds
pop es
Code: Select all
mov esi,CopyPointer
call print_string
... this will display garbage or nothing at all.
NOTE: This code is in the first lines of my OS, so it's using real mode segmentation. After this and other things, it will jump into pmode.
Can you please tell me what the hell I'm doing wrong?
Regards inflater.