/* main kernel routine */ .text # section declaration (code) .globl main main: call cls call clc call printstr ret .size main,.-main /* print string */ printstr: movl $0xb8000,%ebx # set video address (text mode) movl $len,%ecx movl $msg,%esi loop: movb (%esi),%al movb $2,%ah # set green color movw %ax,(%ebx) # print it addl $2,%ebx # next video address addl $1,%esi # next char in string subl $1,%ecx # len-- jne loop ret /* clear screen */ cls: movl $0xb8000,%edi movw $0x0720,%ax movl $80*25,%ecx cld rep stosw ret /* clear cursor */ clc: movw $0x3d4,%dx movb $0xa,%al outb %al,%dx movw $0x3d5,%dx inb %dx,%al andb $0xc0,%al orb $0x1f,%al outb %al,%dx ret .data # section declaration (data) msg: .ascii "Hello world!" # our famous string len = . - msg # string length