94 lines
No EOL
1 KiB
Text
94 lines
No EOL
1 KiB
Text
.load 0x1A40
|
|
|
|
##@struct Rectangle {
|
|
## width:2,
|
|
## height:2,
|
|
## x:2,
|
|
## y:2
|
|
##
|
|
## ## Static properties
|
|
## StructSize
|
|
##}
|
|
|
|
.data
|
|
$cursor_pos 0x00, 0x00
|
|
$color 0x02
|
|
$current_video_addr 0x07, 0xBC
|
|
|
|
$string "Hello World!!"
|
|
|
|
## $rect => Rectangle
|
|
|
|
.code
|
|
debug_break
|
|
infinite_loop:
|
|
push 0
|
|
call $clear_screen
|
|
|
|
## mov $rect.x, 200
|
|
|
|
## debug_break
|
|
|
|
push $string
|
|
push 1
|
|
call $print_string
|
|
|
|
jmp $infinite_loop
|
|
hlt
|
|
|
|
|
|
print_string:
|
|
mov R1, *PP
|
|
dec PP
|
|
dec PP
|
|
|
|
push R1
|
|
push 1
|
|
call $strlen
|
|
mov R2, RV
|
|
|
|
push 65
|
|
push 1
|
|
call $print_char
|
|
ret
|
|
|
|
|
|
strlen:
|
|
mov R1, *PP
|
|
dec PP
|
|
dec PP
|
|
mov R2, 0
|
|
_strlen_loop:
|
|
movb ACC, *R1
|
|
jeq $_strlen_end_loop, 0
|
|
inc R2
|
|
inc R1
|
|
jmp $_strlen_loop
|
|
_strlen_end_loop:
|
|
mov RV, R2
|
|
ret
|
|
|
|
print_char:
|
|
mov R2, *PP
|
|
dec PP
|
|
dec PP
|
|
mov R1, [$current_video_addr]
|
|
mov R3, [$cursor_pos]
|
|
mul R3, 2
|
|
mov R3, ACC
|
|
add R1, R3
|
|
mov R1, ACC
|
|
movb *R1, R2
|
|
inc R1
|
|
movb *R1, [$color]
|
|
mov R3, [$cursor_pos]
|
|
inc R3
|
|
mov [$cursor_pos], R3
|
|
ret
|
|
|
|
clear_screen:
|
|
mov R10, 0x00
|
|
int 0x30
|
|
ret
|
|
|
|
.fixed 512, 0x00 |