Updated the instruction set and mapped out the opcodes as well as wrote a sample program to see if the ISA was complete enough to build a trivial program.
This commit is contained in:
+40
-3
@@ -1,3 +1,40 @@
|
||||
some_stub:
|
||||
pop r8
|
||||
jmp [r8] ;return to the calling code.
|
||||
.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
|
||||
Reference in New Issue
Block a user