[ bits 16] ; tell assembler that working in real mode(16 bit mode) [org 0x7c00] ; organize from 0x7C00 memory location where BIOS will load us start: ; start label from where our code starts xor ax,ax ; set ax register to 0 mov ds,ax ; set data segment(ds) to 0 mov es,ax ; set extra segment(es) to 0 mov bx,0x8000 push dx mov ax,0x13 ;clears the screen int 0x10 ;call bios video interrupt mov ah,02 ;clear the screen with big font int 0x10 ;interrupt displayt ; cursor position mov al, 2 mov ah, 0 mov bl, 4 mov bh, 0 int 0x10 mov si, command_prompt call print_string mov ax,0x00 ; get keyboard input int 0x16 ; interrupt for hold & read input ; load second sector into memory mov ah, 0x02 ; load second stage to memory mov al, 1 ; numbers of sectors to read into memory pop dx ; mov dl, 0x80 ; sector read from fixed/usb disk mov ch, 0 ; cylinder number mov dh, 0 ; head number mov cl, 2 ; sector number mov bx, _OS_Stage_2 ; load into es:bx segment :offset of buffer int 0x13 ; disk I/O interrupt jmp _OS_Stage_2 ; jump to second stage int 0x19 print_string: mov ah, 0x0E ; value to tell interrupt handler that take value from al & print it .repeat_next_char: lodsb ; get character from string cmp al, 0 ; cmp al with end of string je .done_print ; if char is zero, end of string int 0x10 ; otherwise, print it jmp .repeat_next_char ; jmp to .repeat_next_char if not 0 .done_print: ret ;return command_prompt db "myos", 0 ; boot loader magic number times ((0x200 - 2) - ($ - $$)) db 0x00 ;set 512 bytes for boot sector which are necessary dw 0xAA55 ; boot signature 0xAA & 0x55 _OS_Stage_2: mov al,2 ; set font to normal mode mov ah,0 ; clear the screen int 0x10 ; call video interrupt mov si, statement call print_string haltloop: sti hlt jmp haltloop statement db "ok", 0 ; add how much memory we need times (1024 - ($-$$)) db 0x00