Browse Source

No additions, Moved stuff around

special_first_anniversary_edition
Jakob Kjær-Kammersgaard 5 years ago
parent
commit
cfa3eac65c
15 changed files with 190 additions and 156 deletions
  1. +1
    -0
      .gitignore
  2. +1
    -1
      CLI/CLI.nasm
  3. BIN
      SingOS.img
  4. +17
    -0
      build
  5. +1
    -0
      build.sh
  6. BIN
      kernel.bin
  7. +23
    -24
      kernel.nasm
  8. +2
    -2
      legacy/source/build.sh
  9. +119
    -0
      lib/debug_tools.nasm
  10. +0
    -26
      lib/dumpmem.nasm
  11. +7
    -64
      lib/os_lib.nasm
  12. +0
    -20
      lib/printkey.nasm
  13. +2
    -2
      lib/std_power.nasm
  14. +8
    -8
      lib/svim.nasm
  15. +9
    -9
      vsfs/vsfs.nasm

+ 1
- 0
.gitignore View File

@ -1 +1,2 @@
.DS_Store
*.sublime*

+ 1
- 1
CLI/CLI.nasm View File

@ -122,7 +122,7 @@ CLI_EXECUTE:
add bx, bx ; The pointers are two bytes long. This compensates for that.
pusha
call printCRLF_os
call printCRLF
popa
mov dx, [.Command_Function_Pointers + bx] ; Program pointer

BIN
SingOS.img View File


+ 17
- 0
build View File

@ -0,0 +1,17 @@
#!/usr/bin/bash
if [ "$1" == "build" ] || [ "$1" == "run" ]; then
nasm -fbin bootloader.nasm -o bootloader.bin
nasm -fbin kernel.nasm -o kernel.bin
cat bootloader.bin kernel.bin > SingOS.img
if [ $1 == "run" ]; then
#qemu-system-x86_64 -drive format=raw,file=SingOS.img
#qemu-system-x86_64 -hda SingOS.img
qemu-system-x86_64 -drive index=0,if=floppy,format=raw,file=SingOS.img
else
bash -c "echo;echo;echo 'Press [ENTER] to exit'; read line"
fi
fi
echo "Done"

+ 1
- 0
build.sh View File

@ -1,4 +1,5 @@
#!/bin/bash
if [ "$1" != "run" ]; then
nasm -fbin bootloader.nasm -o bootloader.bin
nasm -fbin kernel.nasm -o kernel.bin

BIN
kernel.bin View File


+ 23
- 24
kernel.nasm View File

@ -1,5 +1,5 @@
BITS 16
start_sing_os:
start_sing:
; loading essentials for SingOS to run
; VSFS is loaded:
@ -8,7 +8,7 @@ start_sing_os:
; SingOS is ready for the user:
mov si, welcome ; Put address of the null-terminated string to output into 'si'
call print_os ; Call our string-printing routine
call print ; Call our string-printing routine
mov si, number_one_zstring
call zstring_to_integer
@ -16,14 +16,14 @@ start_sing_os:
mov si, command_line
call print_os
call print
jmp terminal
terminal:
call wait_for_key_os
call wait_for_key
jmp terminal
wait_for_key_os:
wait_for_key:
pusha
mov ax, 0
@ -71,7 +71,7 @@ wait_for_key_os:
.os_buffer_full:
mov si, .os_str_full
call print_os
call print
popa
ret
@ -117,7 +117,7 @@ wait_for_key_os:
.no_str:
mov si, command_line
call print_os
call print
jmp .return_enter
.compare_with_LIST_searchindex dw 0
@ -132,7 +132,7 @@ wait_for_key_os:
.end:
mov si, exit_message
call print_os
call print
call power_off
@ -178,30 +178,30 @@ wait_for_key_os:
mov bx, [.os_command_buffer_counter]
cmp bx, 0x00
je near .no_str ; First byte is 0 => No command
call printCRLF_os
call printCRLF
add bx, .os_command_buffer ; Note addition. Sets bx to the end of the string, which should be guaranteed to be 0
mov ax, 0x00
mov [bx], ax ; Ensure that the command is null-terminated
xor bx, bx
mov [.os_command_buffer_counter], bx
mov si, .os_command_buffer
call print_os ; Echo the command
call print ; Echo the command
lea si, [.os_command_buffer]
;mov dword [.compare_with_LIST_searchindex], 0 ; Next time, start at 0
mov cx, 0 ; Index
.command_interpreter_searchloop:
;call printCRLF_os
;call printCRLF
;mov ax, cx
;call dumpax_os
;call dumpax
;mov bx, [.compare_with_LIST_searchindex]
mov bx, cx
add bx, bx ; The pointers are 2 bytes long. Compensate here
;call printCRLF_os
;call printCRLF
;mov ax, cx
;call dumpax_os
;call dumpax
mov dx, [.compare_with_LIST_NAMES+bx] ; Here it HAS to be bx. Otherwise it is invalid for some reason
mov bx, dx
@ -229,21 +229,21 @@ wait_for_key_os:
jmp .no_str
.command_interpreter_foundcommand:
call printCRLF_os
call printCRLF
;mov bx, [.compare_with_LIST_searchindex] ; Remember this thing
mov bx, cx
add bx, bx ;The pointers are 2 bytes long. Compensate here
;call printCRLF_os
;call printCRLF
;mov ax, cx
;call dumpax_os
;call dumpax
mov dx, [.compare_with_LIST_POINTERS+bx] ; This is where the program is.
;mov ax, dx
;call printCRLF_os
;call dumpax_os
;call printCRLF
;call dumpax
call dx
@ -251,7 +251,7 @@ wait_for_key_os:
;
global_vars_os:
global_vars:
global_vsfs_master_record dw 8 ; this is the index of the start of the master table for the filesystem
; This should maby contain more information.
; and somehow be setted in a fix sector, which holds all the variabels for SingOS
@ -262,7 +262,7 @@ global_vars_os:
; Changed my mind, the index is currently loaded and written back to disk under
; creation of a new file.
data_os:
data:
welcome db 'This is SingOS! v0.0.3', 13, 10, 'Press ESC to halt.', 13, 10, 0
exit_message db 13, 10, 'Goodbye from SingOS',13,10,'The system has halted.', 0
command_line db 13, 10, 'groot@SingOS $ ', 0
@ -271,8 +271,7 @@ data_os:
%include "mem_lib/mem_lib.nasm"
%include "lib/os_lib.nasm"
%include "lib/string.nasm"
%include "lib/dumpmem.nasm"
%include "lib/printkey.nasm"
%include "lib/debug_tools.nasm"
%include "lib/std_power.nasm"
%include "lib/svim.nasm"
%include "vsfs/vsfs.nasm"
@ -280,4 +279,4 @@ data_os:
;times 131072-($-$$) db 0 ; 256 sectos
;GLOBAL_VSFS_START db 'VSFS v0.1' ; sector 257 reserved for file system information
times 1048576-($-$$) db 0 ; sector 258 to sector 2048 should be avaliable to the filesystem.
times (1<<20)-($-$$) db 0 ; sector 258 to sector 2048 should be avaliable to the filesystem.

+ 2
- 2
legacy/source/build.sh View File

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

+ 119
- 0
lib/debug_tools.nasm View File

@ -0,0 +1,119 @@
BITS 16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dumpmem:
; Dumps memory
; IN From-pointer in 'si'
; IN Amount of bytes do dump in 'cx'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pusha
;push ax
;push dx
mov si, start_sing
mov cx, 512
call printCRLF
shr cx, 1
xor dx, dx ; zero dx
.loop:
cmp dx, cx
jae .end
mov ax, word [esi + 2*edx]
call dumpax
mov ax, 0xe20
int 0x10
inc dx
jmp .loop
.end:
;pop dx
;pop ax
popa
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dumpax:
; Prints the contens of ax as a hexadecimal number
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pusha ; save registers
mov dx, ax
mov ah, 0xE ; Teletype output
mov cx, 4 ; 4 nipples in a 16 bit word
.loop:
rol dx, 4 ; rotate to next nipple
mov al, dl ; we copy to al because we need to mask only the low 4 bits
and al, 1111b ; Do the masking
add al, '0' ; convert to ASCII
cmp al, '9' ; If we are greater than 9 ascii, we add 7 to make digit 10 be represented as 'A'
jbe .skip ; -|-
add al, 7 ; -|-
.skip: ; -|-
mov bl, 0xe2 ;color
int 0x10 ; BIOS call 'output'
loop .loop
popa ; restore registers
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dumpax10:
; Prints the contens of ax as a decimal number
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pusha
mov bx, 10 ; Divisor
mov cx, 5 ; Loop 5 times
.loop1: ; finds digits and pushes them to stack
xor dx, dx
div bx
add dl, '0'
push dx
loop .loop1
mov ah, 0xE
mov cx, 5 ; Loop 5 times
mov bl, '0'
.loop2: ; Pops from stack until it hits a non-'0' value. It then jumps to nonzero_nopop to print it.
pop dx
mov al, dl
cmp al, bl
jne .nonzero_nopop
loop .loop2
.nonzero_loop: ; Pops values from the stack and prints them.
pop dx
mov al, dl
.nonzero_nopop: ; Part of the loop that prints the value. Jump to here to print without popping on first iteration.
int 0x10
loop .nonzero_loop
popa
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
keyprint:
; Enters a loop where the keycode of each pressed key is printed
; [ESC] exits the loop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pusha
.keyprint_loop:
mov ax, 0x1000 ; BIOS call to wait for key
int 0x16
cmp ax, 0x11b ; ESC key
je .end_keyprint
call dumpax
mov bx, ax
mov ax, 0xe20
int 0x10 ; print space
mov al, bl
int 0x10 ; print char
call printCRLF
jmp .keyprint_loop
.end_keyprint:
popa
ret

+ 0
- 26
lib/dumpmem.nasm View File

@ -1,26 +0,0 @@
BITS 16
; Routine for dumping memory
; pointer in 'si', length is 'cx'
dumpmem:
pusha
;push ax
;push dx
mov si, start_sing_os
mov cx, 512
call printCRLF_os
shr cx, 1
xor dx, dx ; zero dx
.loop:
cmp dx, cx
jae .end
mov ax, word [esi + 2*edx]
call dumpax_os
mov ax, 0xe20
int 0x10
inc dx
jmp .loop
.end:
;pop dx
;pop ax
popa
ret

+ 7
- 64
lib/os_lib.nasm View File

@ -1,20 +1,20 @@
BITS 16
; Routine for outputting string in 'si' register to screen
print_os:
print:
;mov bh, 0x00
mov bl, 0x02
mov ah, 0xE ; Specify 'int 0x10' 'teletype output' function
; [AL = Character, BH = Page Number, BL = Colour (in graphics mode)]
.printchar_os:
.printchar:
lodsb ; Load byte at address SI into AL, and increment SI
cmp al, 0
je .done_os ; If the character is zero (NUL), stop writing the string
je .done ; If the character is zero (NUL), stop writing the string
int 0x10 ; Otherwise, print the character via 'int 0x10'
jmp .printchar_os ; Repeat for the next character
.done_os:
jmp .printchar ; Repeat for the next character
.done:
ret
printCRLF_os:
printCRLF:
mov ah, 0xE
mov al, 13
int 0x10
@ -33,28 +33,6 @@ printALChar:
int 0x10
ret
dumpax_os:
pusha ; save registers
mov dx, ax
mov ah, 0xE ; Teletype output
mov cx, 4 ; 4 nipples in a 16 bit word
.loop:
rol dx, 4 ; rotate to next nipple
mov al, dl ; we copy to al because we need to mask only the low 4 bits
and al, 1111b ; Do the masking
add al, '0' ; convert to ASCII
cmp al, '9' ; If we are greater than 9 ascii, we add 7 to make digit 10 be represented as 'A'
jbe .skip ; -|-
add al, 7 ; -|-
.skip: ; -|-
mov bl, 0xe2 ;color
int 0x10 ; BIOS call 'output'
loop .loop
popa ; restore registers
ret
; Changing the screen the user i looking at.
; value in 'al' is the screen we want to switch to.
; starting from 0x00
@ -63,39 +41,4 @@ os_change_screen:
; and base pointer has to be set.
mov ah, 0x05
int 0x10
ret
dumpax10: ; Prints ax as 16-bit decimal number
pusha
mov bx, 10 ; Divisor
mov cx, 5 ; Loop 5 times
.loop1: ; finds digits and pushes them to stack
xor dx, dx
div bx
add dl, '0'
push dx
loop .loop1
mov ah, 0xE
mov cx, 5 ; Loop 5 times
mov bl, '0'
.loop2: ; Pops from stack until it hits a non-'0' value. It then jumps to nonzero_nopop to print it.
pop dx
mov al, dl
cmp al, bl
jne .nonzero_nopop
loop .loop2
.nonzero_loop: ; Pops values from the stack and prints them.
pop dx
mov al, dl
.nonzero_nopop: ; Part of the loop that prints the value. Jump to here to print without popping on first iteration.
int 0x10
loop .nonzero_loop
popa
ret
ret

+ 0
- 20
lib/printkey.nasm View File

@ -1,20 +0,0 @@
BITS 16
keyprint:
pusha
.keyprint_loop:
mov ax, 0x1000 ; BIOS call to wait for key
int 0x16
cmp ax, 0x11b ; ESC key
je .end_keyprint
call dumpax_os
mov bx, ax
mov ax, 0xe20
int 0x10 ; print space
mov al, bl
int 0x10 ; print char
call printCRLF_os
jmp .keyprint_loop
.end_keyprint:
popa
ret

+ 2
- 2
lib/std_power.nasm View File

@ -8,8 +8,8 @@ power_check:
mov al,00h ;installation check command
xor bx,bx ;device id (0 = APM BIOS)
int 15h ;call the BIOS function through interrupt 15h
call printCRLF_os
call dumpax_os
call printCRLF
call dumpax
;jc APM_error ;if the carry flag is set there was an error
;the function was successful
;AX = APM version number

+ 8
- 8
lib/svim.nasm View File

@ -2,7 +2,7 @@ BITS 16
svim:
pusha ; save state before program
;mov si, .os_clear_screen_str
;call print_os
;call print
xor bx, bx
mov [.buffer_counter_svim], bx
xor cx, cx ; Upper and left coordinate
@ -19,8 +19,8 @@ svim:
mov dl, 0x17 ; coloumn zero
int 0x10
mov si, .welcome_svim_select_file
call print_os
call printCRLF_os
call print
call printCRLF
call vsfs_list_files_command
; move cursor to the bootom
@ -33,10 +33,10 @@ svim:
int 0x10
mov si, .welcome_svim
call print_os
call printCRLF_os
call print
call printCRLF
mov si, .welcome_svim_enter_fileindex
call print_os
call print
; Ask the user for the filename
xor bx, bx
@ -109,14 +109,14 @@ svim:
; print buffer
mov si, .buffer_for_svim
mov es, si
call print_os
call print
.svim_loop:
mov ax, 0x1000 ; BIOS call to wait for key
int 0x16
cmp ax, 0x1c0d ; enter key
jne .no_enter_fileindex
call printCRLF_os
call printCRLF
jmp .svim_loop
.no_enter_fileindex:
cmp ax, 0x11b ; ESC key

+ 9
- 9
vsfs/vsfs.nasm View File

@ -51,7 +51,7 @@ vsfs_get_fs_info:
int 0x13
mov si, vsfs_loading_buffer
call print_os
call print
popa
ret
@ -121,7 +121,7 @@ vsfs_create_file:
pusha ; save all register state
mov si, .vsfs_create_file_type_filename
call print_os
call print
; Ask the user for the filename
xor bx, bx
@ -151,7 +151,7 @@ vsfs_create_file:
.filename_done:
pop cx ; Cleanup, and now contain filename size
call printCRLF_os
call printCRLF
; We first need to know the index for the file.
@ -239,10 +239,10 @@ vsfs_list_files_command:
int 0x13
mov si, .ls_header
call print_os
call print
mov si, .seperate_line
call print_os
call print
mov ax, [vsfs_loading_buffer + 126]
@ -274,13 +274,13 @@ vsfs_list_files_command:
.stop_index:
mov si, .fileentry_line ; printing the buffer
call print_os
call print
mov si, vsfs_loading_buffer ; printing the buffer
call print_os
call print
call printCRLF_os
call printCRLF
mov si, .seperate_line
call print_os
call print
.end_ls:
popa
ret

Loading…
Cancel
Save