Page 1 of 1

Gnu Assembler bootloader problems

Posted: Sun Sep 07, 2014 8:23 pm
by tomlukeywood
Hello this is my first time posting a question on this forum
i am new to os development and i am trying to write everything from scratch(just a hobby project)
and i am currently writing the bootloader but i found no info on how to make a bootloader
that can boot to a kernel so as there are a few tutorials for nasm
i am trying to convert nasm code to Gnu Assembler
so i started with the disk description
but when i assembled the program i got these errors:

boot.s: Assembler messages:
boot.s:59: Error: junk at end of line, first unrecognized character is `o'
boot.s:65: Error: floating point number invalid
boot.s:65: Error: junk at end of line, first unrecognized character is `h'
boot.s:73: Error: junk at end of line, first unrecognized character is `h'
boot.s:74: Error: junk at end of line, first unrecognized character is `o'
boot.s:75: Error: junk at end of line, first unrecognized character is `A'

as i only understand very basic x86 assembly
i dont rely know what i did wrong
can anyone on these fourms see a problem?
sorry that the code is not formatted well don't know how to fix it i have tried manually fixing it but it still looks werid

original nasm code

Code: Select all

OEMLabel		db "MIKEBOOT"	; Disk label
BytesPerSector		dw 512		; Bytes per sector
SectorsPerCluster	db 1		; Sectors per cluster
ReservedForBoot	dw 1		; Reserved sectors for boot record
NumberOfFats		db 2		; Number of copies of the FAT
RootDirEntries		dw 224		; Number of entries in root dir
				; (224 * 32 = 7168 = 14 sectors to read)
LogicalSectors		dw 2880		; Number of logical sectors
MediumByte		db 0F0h		; Medium descriptor byte
SectorsPerFat		dw 9		; Sectors per FAT
SectorsPerTrack	dw 18		; Sectors per track (36/cylinder)
Sides			dw 2		; Number of sides/heads
HiddenSectors		dd 0		; Number of hidden sectors
LargeSectors		dd 0		; Number of LBA sectors
DriveNo			dw 0		; Drive No: 0
Signature		        db 41		; Drive signature: 41 for floppy
VolumeID		        dd 00000000h	; Volume ID: any number
VolumeLabel		db "MIKEOS     "; Volume Label: any 11 chars
FileSystem		db "FAT12   "	; File system type: don't change!
my Gas code

Code: Select all

###########################################################################
#                      Copyright Tom Lukeywood 2014                                                            # 
#This program is free software: you can redistribute it and/or modify                                #
#    it under the terms of the GNU General Public License as published by                       #
#    the Free Software Foundation, either version 3 of the License, or                               #
#    (at your option) any later version.                                                                            #
#                                                                                                                                #
#    This program is distributed in the hope that it will be useful,                                      #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of                      #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          #
#    GNU General Public License for more details.                                                         #
#                                                                                                                               #
#    You should have received a copy of the GNU General Public License                      #
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.                        #
##########################################################################
.code16                   #generate 16-bit code                          
.text
     .globl _start;
_start:
     #Prints Booting Notix OS 
     movb $'B' , %al
     movb $0x0e, %ah
     int  $0x10
     movb $'o' , %al
     int  $0x10
     movb $'o' , %al
     int  $0x10
     movb $'t' , %al
     int  $0x10
     movb $'i' , %al
     int  $0x10
     movb $'n' , %al
     int  $0x10
     movb $'g' , %al
     int  $0x10
     movb $' ' , %al
     int  $0x10
     movb $'N' , %al
     int  $0x10
     movb $'o' , %al
     int  $0x10
     movb $'t' , %al
     int  $0x10
     movb $'i' , %al
     int  $0x10
     movb $'x' , %al
     int  $0x10
     movb $' ' , %al
     int  $0x10
     movb $'O' , %al
     int  $0x10
     movb $'S' , %al
     int  $0x10
     ###############

     

     ###############
#start of code i am trying to convert from nasm
OEMLabel:		   .byte 'TEST_OS '
bytes_per_sector:	   .byte 512
sectors_per_cluster:	   .byte 1
reserved_for_boot:	   .word 1
number_of_fats:		   .word 2
root_dir_entries:            .word 224		                               		                                                                    
logical_sectors: 	           .word 2880
medium_byte:		  .byte 0F0h		                        
sectors_per_fat: 	  .word 9		                   
sectors_per_track:       .word 18
sides:			  .word 2		                       
hidden_sectors:		 .long 0		                           
large_sectors:		 .long 0			                        
drive_no:		         .word 0		             
signature:		         .byte 41		                                
volume_id:		         .long 48h #the volume id can be any number 48 is my favrote number!                       
volume_label:		 .long 'VOLUME_LABL'                              
file_system:		 .long 'FAT12   '
#end of code i am trying to convert from nasm
     ###############
     . = _start + 510     #mov to 510th byte from 0 pos
     .byte 0x55           #append boot signature
     .byte 0xaa           #append boot signature
     ###############

Re: Gnu Assembler bootloader problems

Posted: Sun Sep 07, 2014 8:33 pm
by alexfru
I don't know about the rest, but why .long here?:
tomlukeywood wrote: volume_label: .long 'VOLUME_LABL'
file_system: .long 'FAT12 '
And what was wrong with NASM?

Re: Gnu Assembler bootloader problems

Posted: Sun Sep 07, 2014 9:31 pm
by zhiayang

Code: Select all

OEMLabel:         .byte 'TEST_OS '
Not going to work. Use either .ascii for raw chars, or .asciz for a NULL terminated one.
Replace the ones below (.long?!) as well. Also, use the string delimiter (double quotes "), not single quotes (').

Code: Select all

bytes_per_sector:        .byte 512
sectors_per_cluster:     .byte 1
reserved_for_boot:       .word 1
number_of_fats:          .word 2
root_dir_entries:        .word 224                                                                                                               
logical_sectors:         .word 2880
All not going to work. You need to prefix your constants with '$', like ".word $224"
You seem to have understood this above, don't know why you can't do it here.

Code: Select all

medium_byte:        .byte 0F0h           
This is not NASM. Hex constants (a) require the '$' prefix as above, and (b) can only be denoted with a '0x' prefix, so you should get

Code: Select all

.byte $0xF0

Re: Gnu Assembler bootloader problems

Posted: Mon Sep 08, 2014 5:06 am
by Icee
@requimrar
In AT&T syntax you don't put dollars in data directives, only in instruction operands. The last line, for example, should read ".byte 0xF0".

Re: Gnu Assembler bootloader problems

Posted: Mon Sep 08, 2014 5:25 am
by tomlukeywood
[ color=#000000 ]
Thanks for your help as i get no errors now
but just while i can ask
do you know of any good bootloader tutoirals for Gnu Assembler
that show you how to boot to a kernel?
[ /color ]


[MOD EDIT] Removed text colouring.

Re: Gnu Assembler bootloader problems

Posted: Mon Sep 08, 2014 5:57 am
by Combuster
I see dark text on a dark background, and the sun is shining onto my screen.

Time to ignore the post and point to the forum rules instead