Memory not been written to correctly in VirtualBox

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
vbguyny
Member
Member
Posts: 48
Joined: Wed Aug 12, 2015 6:30 pm

Memory not been written to correctly in VirtualBox

Post by vbguyny »

I would like to start by says that the following works without any issues in DOSBox and Bochs. However in VirtualBox (5.0), the following code ends up putting data in the wrote extended memory locations.

My OS uses Unreal mode. I have changed the way how my OS enters Unreal mode twice and the code still doesn't work in VirtualBox. Below is the function which copies bytes from conventional memory into extended memory, one byte at a time.

Could someone please let me know if I am doing something wrong or what I should try? I cannot believe that something so fundamental can be broken in VirtualBox. Help!

Code: Select all

Memory.CopyBytesFromFar.Params.SourceSeg equ 12 ; 2 bytes
Memory.CopyBytesFromFar.Params.SourcePtr equ 10 ; 2 bytes
Memory.CopyBytesFromFar.Params.DestinationAddress equ 6 ; 4 bytes
Memory.CopyBytesFromFar.Params.ByteSize equ 4 ; 2 bytes
Memory.CopyBytesFromFar.ParamsSize equ 10
Memory.CopyBytesFromFar.LocalsSize equ 0
Memory.CopyBytesFromFar:
	; Prologue
	enter Memory.CopyBytesFromFar.LocalsSize, 0
	pushad
	push es
	call Memory.ClearGeneralRegisters
	
	mov word es, word [ebp + Memory.CopyBytesFromFar.Params.SourceSeg] 
	mov word si, word [ebp + Memory.CopyBytesFromFar.Params.SourcePtr]
	mov dword edi, dword [ebp + Memory.CopyBytesFromFar.Params.DestinationAddress]
	mov word cx, word [ebp + Memory.CopyBytesFromFar.Params.ByteSize]
	add word cx, word si
	
	; Loop through each byte and assign 0
Memory.CopyBytesFromFar.1:
	mov byte al, byte [es:si]
	mov byte [edi], byte al

	inc dword edi
	inc word si
	cmp word si, word cx
	jb Memory.CopyBytesFromFar.1
	
Memory.CopyBytesFromFar.End:
	; Epilogue
	pop es
	popad
	leave
	ret Memory.CopyBytesFromFar.ParamsSize
Octocontrabass
Member
Member
Posts: 5588
Joined: Mon Mar 25, 2013 7:01 pm

Re: Memory not been written to correctly in VirtualBox

Post by Octocontrabass »

vbguyny wrote:

Code: Select all

	mov byte [edi], byte al
I don't see you setting DS anywhere. What value is in DS?
vbguyny
Member
Member
Posts: 48
Joined: Wed Aug 12, 2015 6:30 pm

Re: Memory not been written to correctly in VirtualBox

Post by vbguyny »

Post Reply