I am a Chinese middle schoole student.
The code is below.
/*head.s start*/
.code16
.text
.global _start
_start:
movw %cs,%ax
movw %ax,%ds
movw %ax,%es
call _init
l:
jmp l
/*head.s end*/
/*init.c start/
int vga_text(void);
int v(void);
int init(void)
{
vga_text();
v();
return(0);
}
/*init.c end*/
/*tool.s start*/
.code16
.text
.global _vga_text,_v
_vga_text:
pushw %bp
movw %sp,%bp
movb $0x00,%ah
movb $0x03,%al
int $0x10
popw %bx
popw %es
popw %bp
ret
_v:
pushw %bp
movw %sp,%bp
pushw %es
pushw %bx
movw $0xb800,%ax
movw %ax,%es
movb $'H',%es:0
movb $0x0a,%es:1
popw %bx
popw %es
popw %bp
ret
/*tool.s end*/
#makefile.txt start#
CC=gcc
LD=ld
AFLAGS = -traditional -c -nostdinc
CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
LDFLAGS= -e _start -Ttext 0x0000 -s --oformat binary
all:head.o init.o tool.o
$(LD) $(LDFLAGSI) -o $@ head.o init.o tool.o
head.o:head.s
$(CC) $(AFLAGS) -o $@ $<
init.o:init.c
$(CC) $(CFLAGS) -c $< -o $@
tool.o:tool.s
$(CC) $(AFLAGS) -o $@ $<
#makefile.txt end#
but the program doesn't do well.
I use NASM to turn the system to system.asm
ndisasm system > system.asm
;system.asm start
00000000 8CC8 mov ax,cs
00000002 8ED8 mov ds,ax
00000004 8EC0 mov es,ax
00000006 E80700 call 0x10
00000009 EBFE jmp short 0x9
0000000B 90 nop
0000000C 90 nop
0000000D 90 nop
0000000E 90 nop
0000000F 90 nop
00000010 83EC0C sub sp,byte +0xc
00000013 E81800 call 0x2e
00000016 0000 add [bx+si],al
00000018 E82000 call 0x3b
0000001B 0000 add [bx+si],al
0000001D 31C0 xor ax,ax
0000001F 83C40C add sp,byte +0xc
00000022 C3 ret
00000023 90 nop
00000024 90 nop
00000025 90 nop
00000026 90 nop
00000027 90 nop
00000028 90 nop
00000029 90 nop
0000002A 90 nop
0000002B 90 nop
0000002C 90 nop
0000002D 90 nop
0000002E 90 nop
0000002F 90 nop
00000030 55 push bp
00000031 89E5 mov bp,sp
00000033 B400 mov ah,0x0
00000035 B003 mov al,0x3
00000037 CD10 int 0x10
00000039 5B pop bx
0000003A 07 pop es
0000003B 5D pop bp
0000003C C3 ret
0000003D 55 push bp
0000003E 89E5 mov bp,sp
00000040 06 push es
00000041 53 push bx
00000042 B800B8 mov ax,0xb800
00000045 8EC0 mov es,ax
00000047 26C606000048 mov byte [es:0x0],0x48
0000004D 26C60601000A mov byte [es:0x1],0xa
00000053 5B pop bx
00000054 07 pop es
00000055 5D pop bp
00000056 C3 ret
00000057 90 nop
00000058 90 nop
00000059 90 nop
0000005A 90 nop
0000005B 90 nop
0000005C 90 nop
0000005D 90 nop
0000005E 90 nop
0000005F 90 nop
00000060 0000 add [bx+si],al
00000062 0000 add [bx+si],al
00000064 0000 add [bx+si],al
;system.asm end
From the system.asm you can see where is error
It is on line 18
There Should be "call 0x3d",but now there is "call 0x3b"
I do feel that is a great error.