Files
assm-test/misc/test.asm
T

34 lines
795 B
NASM

.include "/another_test.asm"
.db video_start 0xF37F
.db msg "Hello, world!", 0
.db NOTERM "No terminating byte here"
.db null_byte 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, null_byte ; 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:
pop r8 ;pop the return address from the stack into register 8
jmp [r8] ;jump to that address