Hello !!
This site is very interresting
I try to start a simple c code from floppy sector boot.
My simple boot code run but the c code doesn't work.
Boot Code
;; bootsect.asm
;;
;; x86 boot code
[BITS 16]
[org 0x07c00]
jmp startb
startb:
;; Update the segment registers
mov ax, cs
mov ds, ax
mov es, ax
mov ah, 9 ; display =
mov al, '=' ; char
mov bx, 7 ; bh/bl
mov cx, 4 ; replicate caracter
int 10h
jmp reset
reset:
mov ah, 9
mov al, '>'
mov bx, 7
mov cx, 2
int 10h
mov ax, 0
mov dl, 0
int 13h
jc reset
jmp read
read:
mov ah, 9
mov al, '+'
mov bx, 7
mov cx, 2
int 10h
mov ax, 0x1000
mov es, ax
mov bx, 0
mov ah, 2 ; mode 2
mov al, 2 ; load n sectors
mov ch, 0 ; cylinder 0
mov cl, 2 ; sector 2
mov dh, 0 ; head=0
mov dl, 0 ; drive =0
int 13h
jc read
mov ah, 9
mov al, 'o'
mov bx, 7
mov cx, 2
int 10h
jmp 0x1000:0x0000
times 510-($-$$) db 0
dw 0AA55h
C code: mytest.c
int go (void)
{
//PRINT_CHAR;
__asm__("
mov 9, %ah
mov 's', %al
mov 7, %bx
mov 2, %cx
int $0x10
");
return 0;
}
Building and loading:
Boot
nasm -f bin bs2.asm
dd if=bs2 of=/dev/fd0 bs=512 count=1
C code
gcc -ffreestanding -O2 -c mytest.c -o mytest.o -nostdlib -fno-uiltin -Wall
ld -o mytest mytest.o -Ttext=0x1000 --oformat binary
dd if=mytest of=/dev/fd0 bs=512 count=2 seek=1
Have you an idea about my problem
Thanks in advance
xixam