28 lines
614 B
NASM
28 lines
614 B
NASM
.db video_start 0xF37F
|
|
.db msg "Hello, world!", 0
|
|
|
|
load r1, [msg] ; Because the lod* instructions can't load an address
|
|
; from anything but a register, this becomes laa r1, [msg]
|
|
|
|
;Routine: string_length
|
|
;In: String address in r1
|
|
;Out: Length in R2
|
|
|
|
string_length:
|
|
loadb r3, [r1] ; Load the byte from the address in R1, into R3
|
|
load r2, 0 ; String length
|
|
cmp r3, 0 ; Is R3 a null byte?
|
|
je end
|
|
inc r2
|
|
|
|
start:
|
|
inc r1 ; next char
|
|
loadb r3, [r1] ; Load the next character byte into R3
|
|
cmp r3, 0 ; Null byte?
|
|
je end
|
|
inc r2 ; Nope, increment the length counter
|
|
jmp start
|
|
|
|
end:
|
|
ret
|