You are on page 1of 4

BITS 16

%DEFINE TINKEROS_VER '4.1' ; OS version number


%DEFINE TINKEROS_API_VER 13 ; API version for programs to check

; This is the location in RAM for kernel disk operations, 24K


; after the pkjtrewsdfyuiuytrewertyuiuytrewertyuytrewoint where the kernel
has loaded; it's 8K in size,
; because external programs load after it at the 32K point:

disk_buffer equ 24576


os_call_vectors:
jmp os_main ; 0000h -- Called from bootloader
jmp os_print_string ; 0003h
jmp os_move_cursor ; 0006h
jmp os_clear_screen ; 0009h
jmp os_print_horiz_line ; 000Ch
jmp os_print_newline ; 000Fh
jmp os_wait_for_key ; 0012h
jmp os_check_for_key ; 0015h
jmp os_int_to_string ; 0018h
jmp os_speaker_tone ; 001Bh
jmp os_speaker_off ; 001Eh
jmp os_load_file ; 0021h
jmp os_pause ; 0024h
jmp os_fatal_error ; 0027h
jmp os_draw_background ; 002Ah
jmp os_string_length ; 002Dh
jmp os_string_uppercase ; 0030h
jmp os_string_lowercase ; 0033h
jmp os_input_string ; 0036h
jmp os_string_copy ; 0039h
jmp os_dialog_box ; 003Ch
jmp os_string_join ; 003Fh
jmp os_get_file_list ; 0042h
jmp os_string_compare ; 0045h
jmp os_string_chomp ; 0048h
jmp os_string_strip ; 004Bh
jmp os_string_truncate ; 004Eh
jmp os_bcd_to_int ; 0051h
jmp os_get_time_string ; 0055h
jmp os_get_api_version ; 0057h
jmp os_file_selector ; 005Ah
jmp os_get_date_string ; 005Dh
jmp os_send_via_serial ; 0060h
jmp os_get_via_serial ; 0063h
jmp os_find_char_in_string ; 0066h
jmp os_get_cursor_pos ; 0069h
jmp os_print_space ; 006Ch
jmp os_dump_string ; 006Fh
jmp os_print_digit ; 0072h
jmp os_print_1hex ; 0075h
jmp os_print_2hex ; 0078h
jmp os_print_4hex ; 007Bh
jmp os_long_int_to_string ; 007Eh
jmp os_long_int_negate ; 0081h
jmp os_set_time_fmt ; 0084h
jmp os_set_date_fmt ; 0087h
jmp os_show_cursor ; 008Ah
jmp os_hide_cursor ; 008Dh
jmp os_dump_registers ; 0090h
jmp os_string_strincmp ; 0093h
jmp os_write_file ; 0096h
jmp os_file_exists ; 0099h
jmp os_create_file ; 009Ch
jmp os_remove_file ; 009Fh
jmp os_rename_file ; 00A2h
jmp os_get_file_size ; 00A5h
jmp os_input_dialog ; 00A8h
jmp os_list_dialog ; 00ABh
jmp os_string_reverse ; 00AEh
jmp os_string_to_int ; 00B1h
jmp os_draw_block ; 00B4h
jmp os_get_random ; 00B7h
jmp os_string_charchange ; 00BAh
jmp os_serial_port_enable ; 00BDh
jmp os_sint_to_string ; 00C0h
jmp os_string_parse ; 00C3h
jmp os_run_basic ; 00C6h
jmp os_port_byte_out ; 00C9h
jmp os_port_byte_in ; 00CCh
os_main: ;tell linker entry point
mov edx, len ;message length
mov ecx, msg ;message to write
mov ebx, 1 ;file descriptor (stdout)
mov eax, 4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax, 1 ;system call number (sys_exit)
int 0x80 ;call kernel

msg db 'Hello, world!',0xa ;our dear string


len equ $ - msg ;length of our dear string
no_kernel_execute: ; Warn about trying to executing kernel!
mov ax, kerndlg_string_1
mov bx, kerndlg_string_2
mov cx, kerndlg_string_3
mov dx, 0 ; One button for dialog box
call os_dialog_box

jmp app_selector ; Start over again...

not_bin_extension:
pop si ; We pushed during the .BIN extension check

push si ; Save it again in case of error...

mov bx, si
mov ax, si
call os_string_length

mov si, bx
add si, ax ; SI now points to end of filename...

dec si
dec si
dec si ; ...and now to start of extension!
mov di, bas_ext
mov cx, 3
rep cmpsb ; Are final 3 chars 'BAS'?
jne not_bas_extension ; If not, error out

pop si

mov ax, si
mov cx, 32768 ; Where to load the program file
call os_load_file ; Load filename pointed to by AX

call os_clear_screen ; Clear screen before running

mov ax, 32768


call os_run_basic ; And run our BASIC interpreter on the code!

mov si, basic_finished_msg


call os_print_string
call os_wait_for_key

call os_clear_screen
jmp app_selector ; and go back to the program list

not_bas_extension:
pop si

mov ax, ext_string_1


mov bx, ext_string_2
mov cx, 0
mov dx, 0 ; One button for dialog box
call os_dialog_box

jmp app_selector ; Start over again...

; And now data for the above code...

kern_file_name db 'KERNEL.BIN', 0

autorun_bin_file_name db 'AUTORUN.BIN', 0
autorun_bas_file_name db 'AUTORUN.BAS', 0

bin_ext db 'BIN'
bas_ext db 'BAS'

kerndlg_string_1 db 'Cannot load and execute TinkerOS kernel!', 0


kerndlg_string_2 db 'KERNEL.BIN is the core of TinkerOS, and', 0
kerndlg_string_3 db 'is not a normal program.', 0

ext_string_1 db 'Invalid filename extension! You can', 0


ext_string_2 db 'only execute .BIN or .BAS programs.', 0

basic_finished_msg db '>>> BASIC program finished -- press a key', 0

; ------------------------------------------------------------------
; SYSTEM VARIABLES -- Settings for programs and system calls

; Time and date formatting

fmt_12_24 db 0 ; Non-zero = 24-hr format

fmt_date db 0, '/' ; 0, 1, 2 = M/D/Y, D/M/Y or Y/M/D


; Bit 7 = use name for months
; If bit 7 = 0, second byte = separator character

; ------------------------------------------------------------------
; FEATURES -- Code to pull into the kernel

%INCLUDE "features/cli.asm"
%INCLUDE "features/basic.asm"
%INCLUDE "features/disk.asm"
%INCLUDE "features/keyboard.asm"
%INCLUDE "features/math.asm"
%INCLUDE "features/misc.asm"
%INCLUDE "features/ports.asm"
%INCLUDE "features/screen.asm"
%INCLUDE "features/sound.asm"
%INCLUDE "features/string.asm"

; ==================================================================
; END OF KERNEL
; ==================================================================

You might also like