FreeBasic Bare Bones: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Nathan (talk | contribs)
Combuster (talk | contribs)
m Reverted edits by Nathan (Talk); changed back to last version by Combuster
Line 114: Line 114:
<!-- GeSHi is *broken*. don't use freebasic as language here !-->
<!-- GeSHi is *broken*. don't use freebasic as language here !-->
<source lang="qbasic">
<source lang="qbasic">
Declare Sub PrintString(src AS Byte Ptr, x AS LONG, y AS LONG)
Declare Sub PrintString(src As Byte Ptr, x As Long, y As Long)
Declare Sub main ()
Declare Sub main ()

Sub multiboot ()
Sub multiboot ()
Asm
const XALIGN = 1 shl 0

const MEMINFO = 1 shl 1
'setting up the Multiboot header - see GRUB docs for details
const FLAGS = XALIGN or MEMINFO
const MAGIC = &h1BADB002
.set ALIGN, 1<<0
const CHECKSUM = -(MAGIC + FLAGS)
.set MEMINFO, 1<<1
const STACKSIZE = &h4000
.set FLAGS, ALIGN | MEMINFO
Asm
.set MAGIC, 0x1BADB002
.align 32
.LONG MAGIC
.set CHECKSUM, -(MAGIC + FLAGS)

.LONG FLAGS
.LONG CHECKSUM
.align 4
.long MAGIC
.long FLAGS
.comm stack, STACKSIZE
.long CHECKSUM

.set STACKSIZE, 0x4000
.comm stack, STACKSIZE, 32
.global loader
.global loader

loader:
loader:
lea esp, [stack + STACKSIZE]
lea esp, stack + STACKSIZE
push eax
push eax
push ebx
push ebx

CALL MAIN
call MAIN

cli
cli
hlt
hlt
End Asm
End Asm

End Sub
End Sub

Sub main ()
Sub main ()
Const s = "Hello World"
Const s = "Hello World"

PrintString CPtr(Byte Ptr, @s), 35, 12
PrintString CPtr(Byte Ptr, @s), 35, 12

End Sub
End Sub

Sub PrintString(src AS Byte Ptr, x AS Long, y AS Long)
Sub PrintString(src As Byte Ptr, x As Long, y As Long)

Dim dst AS Byte Ptr
Dim dst as Byte Ptr
Dim counter AS Long
Dim counter as Long

dst = CPtr(Byte Ptr, &HB8000 + y * 160 + x * 2)
dst = CPtr(Byte Ptr, &HB8000 + y * 160 + x * 2)

counter = 0
counter = 0
While src[counter] <> 0
while src[counter] <> 0
dst[2 * counter] = src[counter]
dst[2 * counter] = src[counter]
dst[2 * counter + 1] = 15
dst[2 * counter + 1] = 15
counter = counter + 1
counter = counter + 1
WEnd
wend
End Sub
End Sub
</source>
</source>