Page 1 of 1
trouble loading function calls
Posted: Wed Feb 29, 2012 3:50 pm
by assembler01
I use for my kernel the mikeos bootloader (
http://mikeos.berlios.de/). I checked in the mikeos kernel and saw how the segments were setup:
Code: Select all
cli
mov ax, 0
mov ss, ax
mov sp, 0FFFFh
sti
cld
mov ax, 2000h
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
And before you question it, yes I know about segments well enough to have made my own hello world bootloader (with a function call), but I found it difficult to make a bootloader to load my kernel. Anyway, I put the above code into my (16 bit) kernel, included the functions for my kernel, and proceeded to load the kernel (I have it in a partition in my hdd) with QEMU, it booted up, told me it found the kernel but the kernel didn't do anything, so I went back to the editor and made a small thing it would do at startup (after the segments were loaded):
When I booted it up it had printed the "o" char to the screen which meant that the system calls where the only things that didn't work. How do I get the system calls to work?
Re: trouble loading function calls
Posted: Wed Feb 29, 2012 3:55 pm
by bubach
What system calls? You said the kernel didn't do anything, and you then added the BIOS call to print a character. Which worked. So I don't see any problem. If you have additional kernel code that doesn't work, it might be a good idea to show it.
Re: trouble loading function calls
Posted: Wed Feb 29, 2012 4:00 pm
by assembler01
Sorry, forgot about that.
Code: Select all
main:
call clean_all ; will clear the screen and clean out the GP regs
.string: db 'Successfully booted!', 0
mov si, .string
call print
hlt
; include the functions:
%include "screen.asm"
%include "clean.asm"
Re: trouble loading function calls
Posted: Wed Feb 29, 2012 4:22 pm
by Unkn0wn1
Have you set the origin of the kernel. And also, what fs are you using in the disk image. Seeing the other files may help, as I am working on something realmode so know my way around...
Also, before you put the HLT instruction at the end of the kernel, put a CLI too. Otherwise, any interrupts will lead to a triple-fault and pulsing of the CPU's RESET pin
Re: trouble loading function calls
Posted: Wed Feb 29, 2012 4:45 pm
by assembler01
What do you mean by "origin of kernel". I use fat12 fs. Here is the print function:
Code: Select all
print:
pusha
.loop:
lodsb
cmp al, 0
je .done
mov ah, 0eh
mov bh, 00h
int10h
jmp .loop
.done:
popa
ret
And here is the cleaning function:
Code: Select all
clean_all:
; clear screen
mov ax, 0600h
mov bh, 07h
mov cx, 0000h
mov dx, 7924h
int 10h
; clean the regs
mov ax, 0
mov bx, 0
mov cx, 0
mov dx, 0
mov si, 0
mov di, 0
ret
Re: trouble loading function calls
Posted: Wed Feb 29, 2012 4:50 pm
by Combuster
The problem is much more simple. You wrote:
Code: Select all
.string: db 'Successfully booted!', 0
The processor sees the following instructions:
Code: Select all
0: e8 1c 00 call 0x1f ; first instruction
3: 53 push %bx ; we come back here after the call and er.... what?
4: 75 63 jne 0x69 ; oops
6: 63 65 73 arpl %sp,0x73(%di)
9: 73 66 jae 0x71
b: 75 6c jne 0x79
d: 6c insb (%dx),%es:(%di)
e: 79 20 jns 0x30
10: 62 6f 6f bound %bp,0x6f(%bx)
13: 74 65 je 0x7a
15: 64 21 00 and %ax,%fs:(%bx,%si)
In other words: keep data away from code.
@Unkn0wn1: Please do not suggest random stuff unless you can also post proof that it's the problem at hand. This is not the first time you were posting irrelevant stuff and you just managed to confuse the OP
Re: trouble loading function calls
Posted: Wed Feb 29, 2012 5:07 pm
by assembler01
I put the .string in the data section but the function calls do not work.