Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Hello , newbie here , please remove this if not the right place
I made this simple boot loaderwith FB , but there are some problems
I can see the character with qemu , but will crash if i use the procedure(prints)
Also the final size is more than 512 bytes(544 bytes)
Can somebody help me ?
declare sub main()
declare sub prints(src AS Byte )
sub start()
asm
.code16
call main
cli
hlt
end asm
end sub
sub main()
asm
mov al,65
mov ah,&h0e
int &H10
end asm
'prints 65
end sub
sub prints(src AS Byte )
dim ch as byte
ch = src
asm
mov al,[ch]
mov ah,&h0e
int &H10
end asm
end sub
sub sig
asm
.org 510
.word 0xAA55
end asm
end sub
declare sub main()
declare sub prints(src AS Byte )
sub start()
asm
.code16
call main
cli
hlt
end asm
end sub
Why not just put main in here rather than calling it? That'lll save a few bytes. Look at the assembly listing your compiler gives you; it's pushing 3 registers before calls and poping them after. That's a lot of wasted code when you're trying to hit a 512 limit.
Look at your assembly listing; there's quite a bit of wasted space adding that extra variable. Also, see if there's some option that does not initialize variables to zero; you waste some space with that.
You can't write naked functions with FreeBasic. You'll always start off with the 32-bit function prologue and the ASM prologue before the content of the ASM block gets executed. All of this is garbage code that gets executed before what you actually wrote as bootloader code does.
Write the whole thing in assembly. There's no Basic code to speak of anyway.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
dim shared vidmem as BYTE PTR = CAST(BYTE PTR, &hB8000)
declare sub Clr ()
declare SUB PrintString(src AS Byte Ptr)
sub main()
const s = "Hello World!"
Clr
PrintString CPtr(Byte Ptr, @s)
hang:
goto hang
end sub
sub Clr ()
dim i as uinteger
for i = 0 to 80*25
vidmem[i*2]=32
Vidmem[i*2+1]=0
next
end sub
SUB PrintString(src AS Byte Ptr)
dim i as uinteger
while (src[i] <> 0 )
vidmem[i*2]=src[i]
vidmem[i*2+1]=7
i += 1
wend
end sub
I don't have much experience with FB but don't you need a cross compiler?
Like, i686-elf-fbc or at least a cross-linker?
BTW You'll run out of space quickly better implement an FS.
There's no formal assumption-free crosscompiler when it comes to FreeBasic, only hacks. The binary itself can be informed of the requested ABI on the command line (using -target, -arch, -fpu, -gen), after which you'll have to potentially supply it with the additional toolchain binaries it will try to use.
BTW You'll run out of space quickly better implement an FS.
So a filesystem takes negative disk space by definition?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Bender wrote:I don't have much experience with FB but don't you need a cross compiler?
Like, i686-elf-fbc or at least a cross-linker?
BTW You'll run out of space quickly better implement an FS.
Thanks , do you think i should use FB-win32-linux-gcc-4.7.3.zip ?
I used ld from FB-win32-dos-binutils-2.23.2.zip for the linker because ld from bin\win32 folder is not very friendly with binary ( cannot perform ...etc)