Printing To Screen: Difference between revisions

[unchecked revision][unchecked revision]
Line 44:
 
For a more advanced print function, you need to store variables for x and y, as the display controller will not print a newline. This involves a switch statement or similar construct.
You also have to test for x>80 or y>25 and in the case of x>80 setting x to 0 and incrementing y, or in the case of y>25 scrolling.
 
In Assembly, you might do
<source lang="asm">
BITS 16
org 0x7c00
 
jmp Main
 
Main:
mov dx, 0xb800
mov es, dx
 
mov si, msg
mov cx, 0
 
Print:
lodsb
cmp al, 0
je Done
 
mov di, cx
mov [es:di], al
inc cx
 
mov di, cx
mov [es:di], 0x07 ; gray (grey) on black
inc cx
 
Done:
mov di, cx ; just in case a character is missing
ret
 
msg db 'Hello World!', 0
</source>
 
==Printing Integers==
Anonymous user