.intel_syntax noprefix
.code16
.org 0x7c00
.text
.global _start
_start:
mov ax, cs # cs = code segment
mov ds, ax # ds = cs
# (this way, we don't have to care much about where our data is located)
mov ax, 0xB800 # 0xB8000 is the base of the text video memory
mov es, ax # Remember the memory model!
mov si, text # Remember that ds:si -> es:di
xor di, di # a xor a is always zero. (di is given the value 0)
around: mov al, [ds:si] # give al the value of what ds:si points to
cmp al, 0 # compare if al contains zero ("Hello world!",0)
je stop # if so, stop writing to the screen
mov [es:di], al # move the content of al to es:di (text video memory)
inc si # select the next byte in the Hello world!-string
add di, 2 # and goto the next position on the screen.
jmp around # and go back to the beginning of the loop
stop: ret # and return back to the caller function
text: .ascii "H`ello world!\0"