flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Memory location

Author
Thread Post new topic Reply to topic
dasyar



Joined: 27 Feb 2005
Posts: 33
dasyar
I have a bootloader prog that loads my kern/prog to 0x10000.
Sample Code:

use16
org 0x10000

mov ax,cs
mov ds,ax

mov esi,msg_ok
call writeetring

jmp $
.
.
.

The above works as expected, when I change org to 0x0000 and change to mov si,msg_ok, this also works fine. But, when I change org back to 0x10000, mov si, msg_ok now causes error: value out of range. Anybody have any ideas why I would get an error.
Post 15 Nov 2005, 15:12
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
The value of SI cannot be greater than 0FFFFh; You get an overflow. Try to set the DS value, for example, MOV AX, 1000h/MOV DS, AX
Post 15 Nov 2005, 15:38
View user's profile Send private message Reply with quote
dasyar



Joined: 27 Feb 2005
Posts: 33
dasyar
I think I may of understated my concern. When I use my boot loader to load the kern/prog to 0x10000 (0x0001:0x0000) location, why would I have to use ESI as opposed to SI. I guess maybe this is a compiler concern, when you choose different org locations, you end up with different results. It seems to me that when you choose ORG 0x0000 or ORG 0x10000, SI should work for both. Basically all you are doing is changing the segment location, meaning the values are still between 0x0000 - 0xffff.
Post 15 Nov 2005, 17:01
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
The address 10000h can be accessed at 0x1000:0x0000, not 0x0001:0x0000. Your source is in 16-bit flat memory model so there is impossible to use SI to store the address of the label. To fix this do that zhak says, load the kern/prog at 0x10000 BUT before jumping to it change DS to 0x1000 (or do it in the loaded code) and use ORG 0.

[edit]Of course there are others pairs of SEG:OFFSET that allows you to access the memory address 0x10000, for example the one that you suggested but with offset 0xFFF0 (0x0001:0xFFF0).[/edit]
Post 15 Nov 2005, 21:42
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.