; Tell NASM that the code's base will be at 7c00h.
; Otherwise it will assume offset 0 when calculating addresses.
org 7c00h
; jump over data
jmp short init
message:
db "Error", 0 ; null-terminated message
clearmsg:
db " ", 0
init:
; Video initalisation
mov ah, 0x00 ; Set video mode
mov al, 0x12 ; VGA mode
int 0x10 ; Video function call interrupt
; Register initialisation
xor ax, ax ; clear ax
mov ds, ax ; ds needs to be 0 for lodsb
cld ; clear direction flag for lodsb
mov dh, 0x0a ; row 10
mov dl, 0x28 ; col 40
main:
; Set cursor position
mov ah, 0x02 ; cursor position
mov bh, 0x00 ; page 0
int 0x10 ; Video function call interrupt
mov si, clearmsg
call string
mov ah, 0x02 ; cursor position
mov bh, 0x00 ; page 0
inc dh
inc dl
int 0x10 ; Video function call interrupt
mov si, message ; move the message's address into si for lodsb
call string ; jump to the string routine
jmp waitblah
; Displays a character
; al: character
char:
mov ah, 0x0e ; Teletype output mode
mov bh, 0x00 ; page number
mov bl, 0x0c ; color (bright red)
int 0x10 ; Video function call interrupt
; print a string
string:
lodsb ; lodsb loads ds:esi into al
cmp al, 0x0
jnz char ; display character if not null
mov cx, 0xFFFF
ret
waitblah:
mov bx, 0xFF
dec cx
waitinner:
dec bx
cmp bx, 0x0
jnz waitinner
cmp cx, 0x0
jnz waitblah
jmp main
; infinite loop
end:
jmp short end
times 0x0200 - 2 - ($ - $$) db 0 ; NASM directive: zerofill up to 510 bytes
dw 0x0AA55 ; Magic boot sector signature
{"text":"text","html5":"html","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"lua","bash":"sh","erlang":"erlang","go":"golang","c":"c_cpp","cpp":"c_cpp","diff":"diff","latex":"latex","sql":"sql","xml":"xml","0":"text","abap":"abap","actionscript":"actionscript","actionscript3":"actionscript","ada":"ada","apache":"apache_conf","applescript":"applescript","asm":"assembly_x86","autohotkey":"autohotkey","closure":"closure","cobol":"cobol","coffeescript":"coffee","cpp-winapi":"c_cpp","c_loadrunner":"c_cpp","c_mac":"c_cpp","c_winapi":"c_cpp","csharp":"csharp","d":"d","dart":"dart","dot":"dot","eiffel":"eiffel","fortran":"fortran","groovy":"groovy","haskell":"haskell","haxe":"haxe","ini":"ini","io":"io","java":"java","java5":"java","make":"makefile","matlab":"matlab","mysql":"mysql","objc":"objectivec","ocaml":"ocaml","pascal":"pascal","perl":"perl","perl6":"perl","postgresql":"pgsql","powershell":"powershell","prolog":"prolog","properties":"properties","rails":"ruby","rust":"rust","scala":"scala","scheme":"scheme","smarty":"smarty","tcl":"tcl","vala":"vala","vb":"vbscript","verilog":"verilog","vhdl":"vhdl","yaml":"yaml"}