flat assembler
Message board for the users of flat assembler.

Index > MenuetOS > "find_free_mem" questions (kernel side)

Author
Thread Post new topic Reply to topic
xemean



Joined: 21 Jan 2004
Posts: 3
xemean 30 Apr 2004, 07:26
I try to modify the kernel files to add some Chinese fuctions ( just for fun),and i need to load the font file to a block of free memory before the first application(launcher) started, the code is:

; load 12*12 Chinese bitmap font file
; cnsbfname db 'SCN12X12BIN'
; cmemlocation dd 0 ; file location

mov esi,boot_cns ; show message
call boot_log
pusha
cli
mov edi,200*1024 ; I don't know edi means,anyone help me?I think it is the size of memory you want ,so i set to 200* 1024(my bitmap font nearly 200k)
call find_free_mem ; call find_free_mem
cmp esi,0 ; no memory available
je .c_error
mov [cmemlocation],esi ; save address to 'cmemlocation'
mov eax,cnsbfname ; eax point to 11 filename
mov ebx,0 ; first block wanted read
mov ecx,-1 ; number of blocks to read
mov edx,[cmemlocation] ; file location
mov esi,12 ; length of filename
call fileread ; read file
; ret ebx = size or 0xffffffff file not found
; eax = 0 ok read or other = errormsg
cmp eax,0
jne .c_error
cmp ebx,-1
jne cok

popa
cli
mov esi,nofontfile
call boot_log
jmp $
.c_error:
popa
cli
mov esi,fileerror
call boot_log
jmp $ ; halted here
cok:
popa

; LOAD FIRST APPLICATION

my question is: "find_free_mem" need edi for what? and the result in esi means what?

i compiled the new kernel,Menuet boot normally. but my own function does not work, the following code may be the problem:

add eax,dword [cmemlocation]

here,eax is the offset of the bitmap. is "cmemlocation" saved the correct address which point to bitmap i want?

dsok:
checkbit:
push eax

movzx eax,word [ecx]
test ah,0x80
jz .checkok1
test al,0x80
jz .checkok1

pop eax ; save positon to ebx

push eax
push ebx
push ecx
push edx
movzx eax,word [ecx]
; mov ax,0xf7c3
movzx edx,ah
and ax,0x00ff
sub al,0xa0
sub dl,0xa0
dec eax
dec edx
imul eax,94
add eax,edx
imul eax,24
add eax,dword [cmemlocation] ;<-- cmemlocation save the addr.?
mov esi,eax
pop edx
pop ecx
pop ebx
pop eax

pusha
mov ecx,ebx
movzx ebx,ax
shr eax,16
call drawcharacter
popa

add eax,13*65536
add ecx,2
sub dx,2
jnz checkbit
popa
ret

.checkok1:
pop eax

letnew:

sorry for my English.
Post 30 Apr 2004, 07:26
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 304
Ville 30 Apr 2004, 08:31
Find_free_mem is only for application management. Menuet uses find_free_mem for searching free memory for a new process. You can load your files directly to a free memory position up to 16mb, see memmap.inc.
Post 30 Apr 2004, 08:31
View user's profile Send private message Reply with quote
xemean



Joined: 21 Jan 2004
Posts: 3
xemean 30 Apr 2004, 09:08
Wink
Thank you
Do you mean i just code as following without set any "flag" to tells system that "this block of memory is useing"?
mov eax,cnsbfname ; eax point to 11 filename
mov ebx,0 ; first block wanted read
mov ecx,-1 ; number of blocks to read
mov edx,0x1000000+0xXXXXXXXX ;<- directly set edx ?
mov esi,12 ; length of filename
call fileread ; read file
Post 30 Apr 2004, 09:08
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 304
Ville 30 Apr 2004, 10:53
xemean wrote:

Do you mean i just code as following without set any "flag" to tells system that "this block of memory is useing"?


You can use the memory from 0 to 16 MB. You don't have to set any flags, since all the used areas are listed in memmap.inc.
Post 30 Apr 2004, 10:53
View user's profile Send private message Reply with quote
xemean



Joined: 21 Jan 2004
Posts: 3
xemean 30 Apr 2004, 11:23
Quote:

You can use the memory from 0 to 16 MB. You don't have to set any flags, since all the used areas are listed in memmap.inc.


Thank you very much,I found a block of free memory for bitmap_font:
; 780000 -> 7fffff free
It is enough.
Greate,I'll post the Simplified Chinese Menuet version later!
Regards,
E-mean X.
Post 30 Apr 2004, 11:23
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 can attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.