Page 1 of 1

Plz help me, my first kernel doent work

Posted: Wed Aug 25, 2004 11:00 pm
by AltCtrlDel
i have written my first simple kernel for x86 real mode using assembly language and C, but it doent work i will be thankful if u can help

it consists of two files kernel1.asm,kernel2.c
it is intended that kernel1.asm starts first,

;;kernel1.asm written for TASM

stack_seg segment stack 'stack'
  db 64 dup(?)
stack_seg ends

_text segment 'code'

assume cs:_text,ds:_data,ss:stack_seg
extrn _main:far

start:
  mov ah,0Eh             ;display prompt
  mov al,[prompt]
  int 10h
  call _main             ;call a C function


_getch proc far          ;a proc to get character
  mov ah,10h
  int 10h
  retf
_getch endp

_putc proc far           ;a proc to print a character
  push bp
  mav bp,sp
  mov ah,0Eh
  mov al,[bp+6]
  int 10h
  pop bp
  retf
_putc endp  

_text ends

_data segment 'data'
  prompt db '$'
_data ends

end start

;;end of kernel1.asm


//kernel2.c

extern char getch();
extern void putc(char c);

char getche()                  ;get character and echo
{
   char c=getch();
   putc(c);
   return c;
}
void main()
{
  char c;
  do
    c=getche();
  while(c!='\n' && c!='\r')
  return;
}


//end of kernel2.c


########steps for building####################

tasm kernel1.asm
tcc -B -c kernel2.c
tlink kernel1.obj kernel2.obj, kernel.exe


i have used a binary editor to remove the exe header from the kernel.exe and moved it to a boot floppy that starts up the file
I have got just the prompt $ and then the system stopped responding,the cursor disappeared.

RE:Plz help me, my first kernel doent work

Posted: Wed Aug 25, 2004 11:00 pm
by ASHLEY4
May be you need some thing like this  " org 0x7C00 " ?,at the start .

\\\\||////
(@@)
ASHLEY4.