[BITS 16] align 4 section .text org 7C00h mov bx,000Fh ;Page 0, colour attribute 15 (white) for the int 10 calls below mov cx,1 ;We will want to write 1 character xor dx,dx ;Start at top left corner mov ds,dx ;Ensure ds = 0 (to let us load the message) cld ;Ensure direction flag is cleared (for LODSB) STACKSIZE equ 0x4000 mov ax,stack+STACKSIZE mov ss,ax mov sp,ax call kernel_main jmp the_end back_space: db 8 end_back_space: message: db ">>>SimpleOS 1.0.0a",13,10,0 end_message: prompt: db "SimpleOS> ",0 end_prompt: crlf: db 13,10,0 end_crlf: exit_str: db "exit",0 date_str: db "date",0 dir_str: db "dir",0 exit_message: db "System shutdown...",13,10,0 end_exit_message: date_message: db "Current date and time...",13,10,0 end_date_message: dir_message: db "Directory listing...",13,10,0 end_dir_message: crt_write_const: push bp mov bp,sp mov si,word [bp+6] mov di,word [bp+4] Char: mov ah,0xE int 10h lodsb inc dl cmp dl,80 jne Skip xor dl,dl inc dh cmp dh,25 jne Skip xor dl,dl Skip: cmp si,di jne Char leave ret crt_write: push bp mov bp,sp push back_space push end_back_space call crt_write_const add sp,4 push word [bp+6] push word [bp+4] call crt_write_const add sp,4 leave ret crt_read: push bp mov bp,sp mov bx,dx lea di,[buffer] mov al,0 .L4: mov [di],byte 0 inc di inc al cmp al,127 jne .L4 lea di,[buffer] ;inc di mov dx,0 .L3: mov ah,0 int 16h inc dx cmp dx,126 je .L2 mov [di],byte al cmp al,byte 13 je .L2 inc di mov ah,0xE int 10h lodsb jmp .L3 .L2: push crlf push end_crlf call crt_write add sp,4 leave ret streq: push bp mov bp,sp mov ax,1 mov si,[bp+4] mov di,[bp+6] .L9: mov cl,byte [di] mov ch,byte [si] inc si inc di mov al,cl cmp al,byte 0 je .L11 mov dl,ch cmp dl,byte 0 je .L11 mov dl,ch mov al,cl cmp byte dl,byte al je .L9 mov ax,0 .L11: leave ret exit_command: push bp mov bp,sp push exit_message push end_exit_message call crt_write add sp,4 .hang: mov ax,0 int 19h jmp .hang leave ret date_command: push bp mov bp,sp push date_message push end_date_message call crt_write add sp,4 leave ret dir_command: push bp mov bp,sp push dir_message push end_dir_message call crt_write add sp,4 leave ret cmd: push bp mov bp,sp push word buffer push word exit_str call streq add sp,4 cmp ax,0 je .L21 call exit_command jmp .L23 .L21: ;push word buffer ;push word date_str ;call streq ;add sp,4 ;cmp ax,0 ;je .L22 ;call date_command ;jmp .L23 .L22: push word buffer push word dir_str call streq add sp,4 cmp ax,0 je .L23 call dir_command .L23: leave ret kernel_main: push bp mov bp,sp xor eax,eax xor ax,ax push message push end_message call crt_write add sp,4 .L1: push prompt push end_prompt call crt_write add sp,4 call crt_read lea di,[buffer] .L5: mov al,byte [di] cmp al,byte 13 je .L10 push word di push word di inc di push word di call crt_write_const add sp,4 pop word di inc di mov al,byte [di] ;cmp al,byte 0dh cmp al,byte 13 jne .L5 .L10: push crlf push end_crlf call crt_write_const add sp,4 call cmd jmp .L1 leave ret section .bss buffer: stack: resb STACKSIZE section .text times 1474560 - 2 - ($ - $$) db 0 ;times 1474560 - 527 db 0 the_end: ENDSTAMP dw 0AA55h stack_start: