Updated the parser to better handle parameters, sort of and including a string length assembly program to use as a test for the whole assembler.
This commit is contained in:
+25
-25
@@ -1,27 +1,27 @@
|
||||
;.org 0x100
|
||||
.db video_start 0xF37F
|
||||
.db msg "Hello, world!", 0
|
||||
.db more_stuff "AA", 0
|
||||
copy r7, msg ; //
|
||||
;cmp r8, msg ;1000 1111
|
||||
;add r4, 0x42
|
||||
;sub r1, r8
|
||||
int 20
|
||||
jz 45
|
||||
jmp msg
|
||||
in 10
|
||||
call more_stuff
|
||||
ret
|
||||
yld
|
||||
|
||||
;copy r1, 45 ;//B0 = 10110000
|
||||
;copy 2, 45
|
||||
;loop:
|
||||
; cmp r1, 0
|
||||
; jz loop
|
||||
; add r1, 1
|
||||
;mov r1, 5 ; move the immediate value 5 into r1
|
||||
;add r1,5 ; add 5 into r1
|
||||
;int 21 ; maybe that will call some string drawing BIOS-like routine
|
||||
;ret
|
||||
; 4 byte header
|
||||
; | Address of First Opcode (2 bytes) | End of Binary (2 bytes) |
|
||||
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
|
||||
cmpi r3, 0 ; Null byte?
|
||||
je end
|
||||
inc r2 ; Nope, increment the length counter
|
||||
jmp start
|
||||
|
||||
end:
|
||||
ret
|
||||
|
||||
Reference in New Issue
Block a user