well this time around just to get a clear picture of whats goin' on i decided to leave the pmode OS for a while and develop a simple real mode console type thingy...
apperntly its not that simple
here is the asm file
simker.asm
Code: Select all
BITS 16
global start
start:
mov ax, cs ; Get the current segment
mov ds, ax ; The data is in this segment
cli ; disable interrupts while changing stack
mov ss, ax ; We'll use this segment for the stack too
mov sp, 0xfffe ; Start the stack at the top of the segment
sti ; Reenable interrupts
mov si, msg ; load address of our message
call putstr ; print the message
hang:
jmp hang ; just loop forever.
; --------------------------------------------
; data for our program
msg db 'Hello from the real world!', 0
; ---------------------------------------------
; Print a null-terminated string on the screen
; ---------------------------------------------
putstr:
lodsb ; AL = [DS:SI]
or al, al ; Set zero flag if al=0
jz putstrd ; jump to putstrd if zero flag is set
mov ah, 0x0e ; video function 0Eh (print char)
mov bx, 0x0007 ; color
int 0x10
jmp putstr
putstrd:
retn
i assemble it using:
Code: Select all
nasmw -f aout simker.asm -o simker.o
Code: Select all
void main()
{
for(;;)
return;
};
Code: Select all
gcc -c C1.c -o C1.o
And here comes the linking part!...
Code: Select all
ld -T kernel.ld simker.o C1.o
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0xFF800000 : {
*(.text)
}
.data : {
*(.data)
}
.bss :
{
*(.bss)
}
}
simker.o(.text+0xf):simker.o: relocation truncated to fit: 16 .text
okay...i know the problem is with the lines using the stack...and that i'am trying to mix a 16 bit asm with a C file(but really the C file does nothing!)
but this looks a fairly simple code right..i mean this should work!!
what might be causing this?
the same linker script worrks fine when i link pmode asm
can u belive this lousy thing kept me up whole night!
HELP