Files
assm-test/misc/another_test.asm
T

40 lines
702 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
je _end
cmp r2, MAX_LENGTH
jg _end
draw_loop:
copy byte [r8], [r1]
inc r1
inc r8
dec r2
cmp r2, 0
je _end
jmp draw_loop
_end:
jmp _end
; 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
cmp [r1], 0
je end ;The string is zero length
loop:
inc r1
cmp [r1], 0
je end
inc r2
jmp loop
end:
ret