Wrote the first batch of directive handling code, so far just handling creating variables.
This commit is contained in:
+1
-28
@@ -1,34 +1,7 @@
|
||||
.include "./another_test.asm"
|
||||
;.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:
|
||||
load byte 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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user