Browse Source

Merge branch 'master' of https://github.com/Rhodez-x/SingOS

special_first_anniversary_edition
Jakob Kjær-Kammersgaard 7 years ago
parent
commit
2fd82e6469
  1. 3
      source/generic_build.sh
  2. 76
      source/mytest.s

3
source/generic_build.sh

@ -0,0 +1,3 @@
as $1.s -o ../compile_folder/$2.o
ld -Ttext 0x7c00 --oformat=binary ../compile_folder/$2.o -o ../compile_folder/$2.bin
dd if=../compile_folder/$2.bin of=../compile_folder/$2.img

76
source/mytest.s

@ -0,0 +1,76 @@
#generate 16-bit code
.code16
#hint the assembler that here is the executable code located
.text
.globl _start;
#boot code entry
_start:
jmp _boot
start: .asciz "Start.\n\r"
error: .asciz "Error.\n\r"
succes: .asciz "Succes.\n\r"
ffs: .asciz "F.\n\r"
end: .asciz "End.\n\r"
.macro mWriteString str #macro which calls a function to print a string
leaw \str, %si
call .writeStringIn
.endm
# function to print the string
.writeStringIn:
lodsb
orb %al, %al
jz .writeStringOut
movb $0x0e, %ah
int $0x10
jmp .writeStringIn
.writeStringOut:
ret
_boot:
mWriteString start
#This goes first as to now overwrite %ah and %al.
mov $0x00, %ax
mov %ax, %es #Section to write into
mov $0x02, %ah # Read sectors from drive
mov $0x01, %al # Number of sectors to read
mov $0x00, %ch # Low 8 bits of cylinder
mov $0x02, %cl # First sector to read (bits 0-5), upper bits of cylinder (bits 6-7)
mov $0x00, %dh # Head number
mov $0x00, %dl # Drive number
# mov $0x00, %es
mov $0xFF, %bx #Offset into section
int $0x13 # Low level disk services
jnc notcarry
mWriteString error
jmp endcarrycheck
notcarry:
mWriteString succes
#fallthrough
endcarrycheck:
mWriteString mystr
mWriteString end
#
#move to 510th byte from the start and append boot signature
. = _start + 510
.byte 0x55
.byte 0xaa
mystr: .asciz "asdf"
. = _start + 1023
.byte 0x00
Loading…
Cancel
Save