Created
March 4, 2022 14:53
-
-
Save alirezaahani/15b92ecf40fd7674c4f3d3b08af1d11d to your computer and use it in GitHub Desktop.
A simple 16bit OS that asks your name and says hello.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAX_STR_LEN equ 100 | |
org 0x7c00 | |
bits 16 | |
mov ax, 0 | |
mov ds, ax | |
mov es, ax | |
mov ss, ax | |
mov sp, 0x7c00 | |
call cls | |
mov si, about | |
call puts | |
mov si, welcome | |
call puts | |
call gets | |
mov si, hello | |
call puts | |
mov si, string_buffer | |
call puts | |
mov si, nextline | |
call puts | |
main_loop: | |
jmp main_loop | |
about db '--- OS MADE BY ALIREZA AHANI ---', 0x0d, 0x0a, 0 | |
welcome db 'Welcome, what is your name? ', 0 | |
hello db 'Hello ', 0 | |
string_buffer times MAX_STR_LEN db 0 | |
nextline db 0x0d, 0x0a, 0 | |
puts: | |
pusha | |
.loop | |
lodsb | |
or al, al | |
jz .done | |
mov ah, 0x0e | |
int 0x10 | |
jmp .loop | |
.done: | |
popa | |
ret | |
gets: | |
mov bx, 0 | |
pusha | |
.loop: | |
mov ah, 0x00 | |
int 0x16 | |
cmp al, 0x0d | |
je .done | |
cmp bx, MAX_STR_LEN | |
je .done | |
mov ah, 0x0e | |
int 0x10 | |
mov byte [string_buffer+bx], al | |
inc bx | |
jmp .loop | |
.done: | |
mov byte [string_buffer+bx], 0x00 | |
mov si, nextline | |
call puts | |
popa | |
ret | |
cls: | |
pusha | |
mov ah, 0x00 | |
mov al, 0x03 | |
int 0x10 | |
popa | |
ret | |
times 510-($-$$) db 0 | |
dw 0xaa55 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment