flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Question about moving data to RAM

Author
Thread Post new topic Reply to topic
Howesr1@yahoo.com



Joined: 28 Apr 2011
Posts: 13
Location: Las Vegas, NV
Howesr1@yahoo.com
Hello.
I hope this is the right place to post this problem.
I hope someone can help me with this problem.
I am writing a bios extension program (for 386+) and I need to create variable data in RAM. (Bios extension does not org 100h a local stack and pushing the variables onto the system stack won't work due to there being several hundred bytes of various sized data.)

what I would like to do it movsb all the data declarations from the rom to Ram. This is what I have, but manipulating the data and printing it to the display does not show any changes to the data occurring. Is there a better solution?

; movsb all the data to 8000h
pushad
push ds
push es

mov ax,8000h
mov es,ax ; now es and ax are pointing to the same place.
lea si,[begindata]
lea di,[begindata]
mov cx,812 ; 812 bytes ; move 300 bytes to ram - plus 512 bytes for buffer. (512 = 256 Dwords)
rep movsb ; move 100 bytes to 8000H
; end of movsb all the data to 8000h


Then I immediately change the variables, store them, and print them.

mov bx,01
xor bx,1021h
mov [storewd],bx
mov ax,[storewd]
call prntAX

mov bx,02
xor bx,1021h
mov [crc],bx
mov ax,[storewd]
call prntAX



I read somewhere that user accessible RAM starts at 80,000. That does not seem to work either.

Any help or advice is appreciated

Thank you and best regards

_________________
Bob's your uncle. Millie's your aunt.
Post 06 May 2011, 17:32
View user's profile Send private message Send e-mail Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
I'm may be wrong here but the only BIOS locations I know of are:

0x00400 - 0x00600
0x9FC00 - 0xA0000 (this can vary)
0xE0000 - 0xFFFFF

----

The accessible range is 0x00000 - 0xFFFFF unless you have less than 1MB of RAM.

Looking at your code, you've set es to 0x8000 which translates to linear address 0x80000 but your print routines don't access this buffer and simply move the constant 0x1020 to ax every time; you'd have to do something like mov ax, word [es:0].
Post 06 May 2011, 19:10
View user's profile Send private message Reply with quote
Howesr1@yahoo.com



Joined: 28 Apr 2011
Posts: 13
Location: Las Vegas, NV
Howesr1@yahoo.com
I got the answer from someone. I have to set ds to the 8000 that's in es after the movsb: push es and pop ds. Now ds points to 8000h and the expansion rom chip now has dynamic RAM variables instead of static ROM values located at label begindata $ (for a total of 812 bytes of variable.)

_________________
Bob's your uncle. Millie's your aunt.
Post 06 May 2011, 20:55
View user's profile Send private message Send e-mail Reply with quote
Howesr1@yahoo.com



Joined: 28 Apr 2011
Posts: 13
Location: Las Vegas, NV
Howesr1@yahoo.com
Thank you cod3b453.

Now that that is resolved, Int 13 AH,42 returns ah=01, invalid parameter

mov ax,08000h ;8000h
mov es,ax ; now es and ax are pointing to the same place.
lea si,[begindata]
lea di,[begindata]
mov cx,812 ; bytes ; move 300 bytes to ram - plus 512 bytes for iobuff. (512 = 256 Dwords)
rep movsb ; move 100 bytes to 8000H
push es ; this pushed 812 onto the stack
pop ds ; now pop 8000h off the stack - ds now points to 8000h

mov dl,80h ; hard disk 1
lea si,[lbaio] ; lbaio
mov ah,42h ;read
int 13h
jc notok <<< jumps to Not Ok

>>> never gets here <<<<<<
Ah returns as 01
01h invalid function in AH or invalid parameter

Can anyone explain why this might be?

_________________
Bob's your uncle. Millie's your aunt.
Post 07 May 2011, 00:00
View user's profile Send private message Send e-mail Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
int 13h, AH 42h
parameters

dl-Drive number
ds:si-segment and offset to DAP


Last edited by typedef on 07 May 2011, 18:33; edited 1 time in total
Post 07 May 2011, 05:21
View user's profile Send private message Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC
512 Bytes is 128 Dwords (in the x86-style of DWORD)

mov cx, 812
rep movsb

the movsb doesn't update ES it updates SI and DI..
the rep updates CX (at the end of the movsb it becomes zero).
Post 07 May 2011, 12:20
View user's profile Send private message Visit poster's website Reply with quote
Howesr1@yahoo.com



Joined: 28 Apr 2011
Posts: 13
Location: Las Vegas, NV
Howesr1@yahoo.com
Thank you typedef and BAiC. I'm a noob. I've got manuals to read! Like, what is the DAP?

As I read your response again I see: SI and DI!

So Int 13 return is telling the truth. The destination buffer parameter is not valid.

Thanks again!


Last edited by Howesr1@yahoo.com on 08 May 2011, 19:44; edited 1 time in total
Post 08 May 2011, 16:37
View user's profile Send private message Send e-mail Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC
calculating ROM addresses vs. physical addresses isn't particularly difficult.

it's information that's needed most of all: Where are you trying to Read From and where are you trying to write to?

The formula, by the way, is 16*Segment + LinearAddress.
Post 08 May 2011, 16:46
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

off topic, sorry... just this,

What OS are you using to use an interrupt like int13 ?

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 08 May 2011, 17:47
View user's profile Send private message Send e-mail Reply with quote
Howesr1@yahoo.com



Joined: 28 Apr 2011
Posts: 13
Location: Las Vegas, NV
Howesr1@yahoo.com
Hi BAiC
Int 13 ah42 reads the hard disk 01 and should be putting the 512 byte sector idata nto lbaio. (I used 812 bytes to allow creation of additional variable data to be used above the 512 hd data: indexes, counts, strings, etc.) lbaio and other variables are declared in the ROM, but rom is an OTP with no stack or data space so I had to movsb it to RAM, which is where all the trouble starts!

Hi ouadji
No os, or maybe the bios uses a version of DOS assembly language. I'm programming a bios extension device.
Post 08 May 2011, 20:04
View user's profile Send private message Send e-mail Reply with quote
Howesr1@yahoo.com



Joined: 28 Apr 2011
Posts: 13
Location: Las Vegas, NV
Howesr1@yahoo.com
I've been experimenting with how to set si and ds to point to the 8000h offset for use with int 13 ah42 hard drive read with no success. I always get ah=01 invalid parameter. does anyone have any ideas?

No matter what I set ds and si to I get that same error code.

push ds
push es

mov ax,08000h ;8000h
mov es,ax ; now es and ax are pointing to the same place.
lea si,[begindata]
lea di,[begindata]
mov cx,812 ; bytes ; move 300 bytes to ram - plus 512 bytes for iobuff. (512 = 256 Dwords)
rep movsb ; move 100 bytes to 8000H

mov ax,08000h ;8000h
mov es,ax ; now es and ax are pointing to the same place.
push es ; this pushed 800h onto the stack
pop ds ; now pop 8000h off the stack - ds now points to 8000h


mov dl,80h ; hard disk 1
lea si,[lbaio] ; lbaio
mov ah,42h ;read
int 13h

jc notok

ret

_________________
Bob's your uncle. Millie's your aunt.
Post 08 May 2011, 21:03
View user's profile Send private message Send e-mail Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
move variables first then code.

destination address=0800h

label_vars:
myword dw ? ;2 bytes here
mystring db 'hello world',0 ; 12 bytes here, 14 bytes total.

first copy those to ram @ SI like this. note this is rather slow than just using rep movsb.
mov si,label_vars
mov di,08000h ; segment + offset
mov cx,14
@@:
lodsb
cmp cx,0
je @F
movsb
dec cx
jmp @B
@@:
; now when in ram, myword will be at 08000h linear and my string will be at 08003h linear

your code should start at 080012h linear
Post 08 May 2011, 23:14
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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.