cannot find a way to link kernel
Posted: Sat Apr 07, 2012 1:09 pm
before I get started here is the codes:
start.asm
graphics.h
main.c
I am using nasm and GCC at the moment.
I'm running into the problem where LD cannot link 16-BIT instructions.
Does anyone know any tricks or another linker that I can use.
I cannot put the video and PMode loader in my bootsector wich is already pushing 508 bytes
start.asm
Code: Select all
bits 16 ; we are still in real mode
; we are loaded at linear address 0x10000
jmp main ; jump to main
main:
;set graphincs mode 320x200 256 colors
mov ah, 00
mov al, 13
int 10h
;enterPMode
cli
xor ax, ax
mov ds, ax
lgdt [toc]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 08h:clean_up
bits 32
global kernel
extern _k_main
clean_up:
mov ax, 10h
mov ds, ax
mov ss, ax
mov esp, 090000h
kernel:
call _k_main
cli
hlt
gdt_data:
dd 0
dd 0
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
db 0
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
end_of_gdt:
toc:
dw end_of_gdt - gdt_data -1
dd gdt_dataCode: Select all
char *vga = 0xA0000;
void pset(int x, int y, char color)
{
vga[(y * 320) + x] = color;
}Code: Select all
#include "graphics.h"
k_main()
{
int xx = 0;
int yy = 0;
for (xx = 0; xx < 320; xx++)
{
for (yy = 0; yy < 200; yy++)
{
pset(xx, yy, 17);
}
}
}I'm running into the problem where LD cannot link 16-BIT instructions.
Does anyone know any tricks or another linker that I can use.
I cannot put the video and PMode loader in my bootsector wich is already pushing 508 bytes