hello there. Ive recently got into OS development, and looked at Fritz os on bona-fide which btw i think is the best place for a newbie to start.
My problem is, on the bootsector. How much do i have to load?
Quite simply i have the bootloader, which launches the preloading kenel (ASM) which refers to the main kernel written in C once this is done im in PMode. The question is, in the bootsector do i have to load the entire size of the kernel (Including header files) before doing the int 0x13 or can i load just the primary C file. And then leave asm good an proper (as i'll be happy once im once ive solved all the asm troubles).
The next question is, when compiling on gcc, how would i go about including MY written headers (not the inbuilt ones), would gcc simply look relative to the kernel.c file and then compile the headers too.
Last one, does anyone know a good routine for performing a scanf in C (for my custom stdio.h header) ive got a working printf (with %d and %s etc.) but i expect a scanf to be harder.
Thanks very much in advance.
Somebody new
RE:Somebody new
Here's the one I use. Its less then ideal but works great for console IO. I used it as an interrupt handler so it terminates with an IRET. You'll want to fix that if your using it as a procedure. It handles backspace fine but the arrow keys don't work. If you get them working or make any other improvements can you send them back to me at <robeddielee at hotmail dot com>? Also I think this forum will mess up the formatting (indentation and such) so if you want it as an .asm file, just email me.
-Robert
AH_3h:
mov dx, di ; Remember initial offset
getkey:
xor ax, ax ; Get a key
int 16h
cmp al, 13 ; Enter?
je AH_3hd
cmp al, 8 ; Backspace?
je backspace
mov bx, di ; Are we at CX bytes already?
sub bx, dx
cmp bx, cx
jae getkey
mov ah, 0Eh ; Write Character
mov bx, 0001h
int 10h
cmp al, 65 ; Lowercase only
jb writeit
cmp al, 90
ja writeit
add al, 32
writeit: ; Got a key
stosb ; Record and display keystroke
jmp getkey
backspace:
cmp di, dx ; Beginning of string?
je noback
dec di ; Go back in buffer
mov al, 8 ; Move cursor back
mov ah, 0Eh
mov bx, 0001h
int 10h
mov al, 32 ; Print a space
mov ah, 0Eh
mov bx, 0001h
int 10h
mov al, 8 ; Move cursor back again
mov ah, 0Eh
mov bx, 0001h
int 10h
jmp getkey ; Get another key
noback:
mov ah, 5 ; BEEP!
int 20h
jmp getkey ; Get another key
AH_3hd: ; Finish up
mov cx, di ; CX = byte count
sub cx, dx
xor al,al ; Zero-terminate
stosb
xor ax, ax ; Success
iret ; Return
-Robert
AH_3h:
mov dx, di ; Remember initial offset
getkey:
xor ax, ax ; Get a key
int 16h
cmp al, 13 ; Enter?
je AH_3hd
cmp al, 8 ; Backspace?
je backspace
mov bx, di ; Are we at CX bytes already?
sub bx, dx
cmp bx, cx
jae getkey
mov ah, 0Eh ; Write Character
mov bx, 0001h
int 10h
cmp al, 65 ; Lowercase only
jb writeit
cmp al, 90
ja writeit
add al, 32
writeit: ; Got a key
stosb ; Record and display keystroke
jmp getkey
backspace:
cmp di, dx ; Beginning of string?
je noback
dec di ; Go back in buffer
mov al, 8 ; Move cursor back
mov ah, 0Eh
mov bx, 0001h
int 10h
mov al, 32 ; Print a space
mov ah, 0Eh
mov bx, 0001h
int 10h
mov al, 8 ; Move cursor back again
mov ah, 0Eh
mov bx, 0001h
int 10h
jmp getkey ; Get another key
noback:
mov ah, 5 ; BEEP!
int 20h
jmp getkey ; Get another key
AH_3hd: ; Finish up
mov cx, di ; CX = byte count
sub cx, dx
xor al,al ; Zero-terminate
stosb
xor ax, ax ; Success
iret ; Return