FreeBasic Bare Bones: Difference between revisions

[unchecked revision][unchecked revision]
(fixed <pipe> and compiler issues as posted by ScorchOS)
Line 114:
<!-- GeSHi is *broken*. don't use freebasic as language here !-->
<source lang="qbasic">
Declare Sub PrintString(src AsAS Byte Ptr, x AsAS LongLONG, y AsAS LongLONG)
Declare Sub main ()
 
Sub multiboot ()
const XALIGN .set= ALIGN,1 shl 1<<0
Asm
.setconst MEMINFO, = 1<< shl 1
 
.setconst FLAGS, = XALIGN ALIGN |or MEMINFO
'setting up the Multiboot header - see GRUB docs for details
.setconst MAGIC, = 0x1BADB002&h1BADB002
const CHECKSUM = -(MAGIC + FLAGS)
.set ALIGN, 1<<0
const STACKSIZE = &h4000
.set MEMINFO, 1<<1
Asm
.set FLAGS, ALIGN | MEMINFO
.longalign FLAGS32
.set MAGIC, 0x1BADB002
.setLONG CHECKSUM, -(MAGIC + FLAGS)
.LONG FLAGS
 
.alignLONG 4CHECKSUM
.long MAGIC
.comm stack, STACKSIZE, 32
.long FLAGS
.long CHECKSUM
 
.set STACKSIZE, 0x4000
.comm stack, STACKSIZE, 32
.global loader
 
loader:
lea esp, [stack + STACKSIZE]
push eax
push ebx
 
callCALL MAIN
 
cli
hlt
End Asm
 
End Sub
 
Sub main ()
Const s = "Hello World"
 
PrintString CPtr(Byte Ptr, @s), 35, 12
 
End Sub
 
Sub PrintString(src AsAS Byte Ptr, x AsAS Long, y AsAS Long)
 
Dim dst asAS Byte Ptr
Dim counter asAS Long
 
dst = CPtr(Byte Ptr, &HB8000 + y * 160 + x * 2)
 
counter = 0
whileWhile src[counter] <> 0
dst[2 * counter] = src[counter]
dst[2 * counter + 1] = 15
counter = counter + 1
wendWEnd
End Sub
</source>
34

edits