Files
assm-test/misc/another_test.asm
T

44 lines
774 B
NASM

.db MAX_MEM 0xFFFF
.db VIDEO_MEM 0xF37F
.db MAX_LENGTH MAX_MEM; - MAX_LENGTH
.db MSG "Hello, World!", 0
__start:
copy r1, MSG ; Pointer into r1
copy r8, VIDEO_MEM
call strlen
copy r1, MSG
cmp r2, 0
jz _end
cmp r2, MAX_LENGTH
jg _end
draw_loop:
copy byte [r8], [r1]
inc r1
inc r8
dec r2
cmp r2, 0
jz _end
jmp draw_loop
_end:
jmp _end
.db NewMsg "My message", 0
; Returns the length of a NULL terminated string
; Arguments: R1 - Pointer to the string
; Returns: R2 - Contains the length of the string
strlen:
copy r2, 0 ; length
copy byte r3, [r1]
cmp r3, 0
jz end ;The string is zero length
loop:
inc r1
copy byte r3, [r1]
cmp r3, 0
jz end
inc r2
jmp loop
end:
ret