Junk At End Of Line, First Unrecognized Character Is ','

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.
Locked
User avatar
Nathan
Member
Member
Posts: 201
Joined: Sun Jul 19, 2009 1:48 pm
Location: Brazil
Contact:

Junk At End Of Line, First Unrecognized Character Is ','

Post by Nathan »

Hello,
I'm testing the FreeBASIC to develop a OS with a wiki entry. With this code:

Code: Select all

DECLARE SUB PrintString(src AS Byte Ptr, x AS LONG, y AS LONG)
DECLARE SUB main ()
 
SUB multiboot ()
   Asm
 
     'setting up the Multiboot header - see GRUB docs for details
 
     .set ALIGN,    1<<0             
     .set MEMINFO,  1<<1             
     .set FLAGS,    ALIGN | MEMINFO  
     .set MAGIC,    0x1BADB002       
     .set CHECKSUM, -(MAGIC + FLAGS) 
 
     .align 4
     .LONG MAGIC
     .LONG FLAGS
     .LONG CHECKSUM
 
     .set STACKSIZE, 0x4000          
     .comm stack, STACKSIZE, 32      
 
     .global loader                  
 
     loader:
       lea   esp, stack + STACKSIZE
       push  eax                       
       push  ebx                       
 
       CALL  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 AS Byte Ptr, x AS LONG, y AS LONG)
 
    DIM dst AS Byte Ptr
    DIM counter AS LONG
 
    dst = CPtr(Byte Ptr, &HB8000 + y * 160 + x * 2)
 
    counter = 0
 
    WHILE src[counter] <> 0
        dst[2 * counter] = src[counter]
        dst[2 * counter + 1] = 15
        counter = counter + 1
    WEND
END SUB
But when I've tried to compile the code I got this:

Code: Select all

C:\Documents and Settings\Nathan Campos\Desktop>fbc -c kernel.bas -o kernel.o
kernel.asm: Assembler messages:
kernel.asm:24: Error: junk at end of line, first unrecognized character is `,'

C:\Documents and Settings\Nathan Campos\Desktop>
What is wrong?

Best Regards,
Nathan Paulino Campos
User avatar
Nathan
Member
Member
Posts: 201
Joined: Sun Jul 19, 2009 1:48 pm
Location: Brazil
Contact:

Re: Junk At End Of Line, First Unrecognized Character Is ','

Post by Nathan »

I've solved the problem, the code needs to be like this:

Code: Select all

DECLARE SUB PrintString(src AS Byte Ptr, x AS LONG, y AS LONG)
DECLARE SUB main ()
 
SUB multiboot ()
   const XALIGN = 1 shl 0             
   const MEMINFO = 1 shl 1             
   const FLAGS = XALIGN or MEMINFO
   const MAGIC = &h1BADB002       
   const CHECKSUM = -(MAGIC + FLAGS)
   const STACKSIZE = &h4000
   Asm 
     .align 32
     .LONG MAGIC
     .LONG FLAGS
     .LONG CHECKSUM
          
     .comm stack, STACKSIZE      
 
     .global loader                  
 
     loader:
       lea   esp, [stack + STACKSIZE]
       push  eax                       
       push  ebx                       
 
       CALL  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 AS Byte Ptr, x AS LONG, y AS LONG)
 
    DIM dst AS Byte Ptr
    DIM counter AS LONG
 
    dst = CPtr(Byte Ptr, &HB8000 + y * 160 + x * 2)
 
    counter = 0
 
    WHILE src[counter] <> 0
        dst[2 * counter] = src[counter]
        dst[2 * counter + 1] = 15
        counter = counter + 1
    WEND
END SUB
The code in the wiki is too much wrong!
Locked