diff --git a/README.md b/README.md index 4bc064b..4a35c9f 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ dd if=.bin of=/dev/sdX && sync ``` > [!IMPORTANT] -> Make sure to replace `.bin` with your downloaded/compiled binary name and **make sure to replace `/dev/sdX` with your USB's actual partition number. **Any data on it will be lost!** +> Make sure to replace `.bin` with your downloaded/compiled binary name and make sure to replace `/dev/sdX` with your USB's actual partition number. **Any data on it will be lost!** > [!NOTE] >You can choose the device to boot off of from your BIOS boot menu (accessible by pressing F8 or F12). diff --git a/asm/boot.asm b/asm/boot.asm index 7fe6f8b..a889cfd 100644 --- a/asm/boot.asm +++ b/asm/boot.asm @@ -11,112 +11,120 @@ _start: xor ax, ax mov ds, ax mov es, ax - mov bx, boot_msg - call print + mov cx, ax ;clear registers + mov bx, boot_msg + call print ;print the boot message - jmp shell - - jmp $ + jmp shell ;jmp to the shell + jmp $ ;failsafe - jmp to itself shell: mov ah, 0xE mov al, '>' - int 0x10 + int 0x10 ;print a '>' mov bx, nl - call print + call print ;print the shell prompt .input: - mov cl, 0 - mov bx, buffer + mov cl, 0 ;initialize character counter + mov bx, buffer ;move the buffer address into bx .get_input_loop: mov ah, 0 - int 0x16 + int 0x16 ;get keypress - cmp al, 0x8 - je .check_buffer + cmp al, 0x8 + je .check_buffer ;check if backspace cmp al, 0xD - je .print_input + je .print_input ;check if return key cmp al, 0x20 - jb .get_input_loop + jb .get_input_loop ;check if special key cmp al, 0x7F - jae .get_input_loop + jae .get_input_loop ;check if special key cmp cl, 255 - je .get_input_loop + je .get_input_loop ;check if buffer is full mov ah, 0xE - int 0x10 + int 0x10 ;print input character - mov [bx], al - inc bx - inc cl + mov [bx], al ;add input character to the buffer + inc bx ;make bx point to the next location of the buffer + inc cl ;increment character counter jmp .get_input_loop -.check_buffer: +.check_buffer: cmp cl, 0 - je .get_input_loop - jne .backspace + je .get_input_loop ;if buffer is empty jmp back to the input loop + jne .backspace ;if not, handle backspace .backspace: - dec bx - mov ch, 0 - mov [bx], ch - dec cl + dec bx ;make bx point to the previous character of the buffer + mov [bx], ch ;remove it from the buffer + dec cl ;decrement character counter + mov ah, 0xE mov al, 0x8 - int 0x10 + int 0x10 ;move the cursor one character back mov al, 0 - int 0x10 + int 0x10 ;overwrite the last entered character with a blank character mov al, 0x8 - int 0x10 - jmp .get_input_loop + int 0x10 ;move the cursor one character back + + jmp .get_input_loop ;jmp back to the input loop .print_input: mov ah, 0xE mov al, 0xA - int 0x10 + int 0x10 mov al, 0xD - int 0x10 - mov bx, buffer - mov ch, 0 + int 0x10 ;print newline + + mov bx, buffer ;move buffer start address into bx .print_input_loop: - mov al, [bx] - cmp al, 0 - je .end_print_input - int 0x10 - mov [bx], ch - inc bx - jmp .print_input_loop + mov al, [bx] + + cmp al, 0 ;check if current character is a NULL-terminator + je shell ;if yes, stop printing + + int 0x10 ;if not, print the character -.end_print_input: - jmp shell + mov [bx], ch ;clear current buffer location + inc bx ;make bx point to the next character of the buffer + + jmp .print_input_loop print: mov ah, 0xE -.print_loop: - mov al, [bx] - cmp al, 0 - je back - int 0x10 - inc bx - jmp .print_loop +.print_loop: ;basically print_input_loop, but it doesnt clear the character after printing + mov al, [bx] + + cmp al, 0 ;check if current character is a NULL-terminator + je back ;if yes, stop printing + + int 0x10 ;if not, print the character + inc bx ;make bx point to the next character of the string + + jmp .print_loop back: - ret + ret ;return cls: pusha + mov ah, 0x00 mov al, 0x03 - int 0x10 + int 0x10 ;clear screen buffer + popa - ret + + ret ;return boot_msg: db 13, 10, "HighlightOS v0.0.1", 13, 10, 10, " Copyright (C) 2024", 13, 10, " Adam Perkowski", 0 nl: db 13, 10, 10, "hls <", 0