summaryrefslogtreecommitdiff
path: root/programs/sub-suite/tmp-stuff/test-size.s
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-02-13 13:59:48 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2021-02-13 13:59:48 -0500
commit8d7f27d9a0b61d3694a62f3e54be885d8073f02b (patch)
treeb505454c79dba2e691ee19f716ccfd0d0aba1430 /programs/sub-suite/tmp-stuff/test-size.s
parentac778a4d39ba6c80651ce20ce780dfe859c3dcff (diff)
- Reverted back one commit before the previous commit.
This is because the previous commit actually created a bug, rather than fixing one. - Added JMP, and JSR to the ortho extension, and implemented them both in the assembler, and emulator.
Diffstat (limited to 'programs/sub-suite/tmp-stuff/test-size.s')
-rw-r--r--programs/sub-suite/tmp-stuff/test-size.s59
1 files changed, 59 insertions, 0 deletions
diff --git a/programs/sub-suite/tmp-stuff/test-size.s b/programs/sub-suite/tmp-stuff/test-size.s
new file mode 100644
index 0000000..b543a36
--- /dev/null
+++ b/programs/sub-suite/tmp-stuff/test-size.s
@@ -0,0 +1,59 @@
+MAGIC = $AA
+
+
+.org 0
+findramend:
+ and #0 ; Reset A.
+; lda #MAGIC ; Set A to a magic number.
+@loop:
+ mov a, (d) ; Preserve the value.
+ mov (d), #MAGIC ; Write the magic number to the current end of RAM.
+ cmp (d), #MAGIC ; Is the value in RAM, the same as the magic number we wrote?
+ bne @moveback ; No, so move back until we find the last writable memory location.
+ mov (d), a ; Yes, so restore the previous value.
+ add.w d, #$4000 ; Increment the end of RAM pointer by 16K.
+ bra @loop ; Keep looping.
+@moveback:
+ dec d ; Decrement the end of RAM pointer.
+ mov a, (d) ; Preserve the value.
+ mov (d), #MAGIC ; Write the magic number to the current end of RAM.
+ cmp (d), #MAGIC ; Is the value in RAM, the same as the magic number we wrote?
+ bne @moveback ; No, so keep looping.
+ mov (d), a ; Yes, so restore the previous value.
+@end:
+ mov a, d ; Return the end of RAM pointer.
+; ple.q ; Restore E.
+ rts ; End of findramend.
+
+
+;findramend:
+; phe.q ; Preserve E.
+; phb.q ; Preserve B.
+; mov e, d ; Set E to the RAM pointer.
+; and #0 ; Reset A.
+; lda #MAGIC ; Set A to a magic number.
+;@loop:
+; ldb (e) ; Preserve the value.
+; sta (e) ; Write the magic number to the current end of RAM.
+; cmp (e) ; Is the value in RAM, the same as the magic number we wrote?
+; bne @moveback ; No, so move back until we find the last writable memory location.
+; stb (e) ; Yes, so restore the previous value.
+; ade.w #$4000 ; Increment the end of RAM pointer by 16K.
+; bra @loop ; Keep looping.
+;@moveback:
+; dee ; Decrement the end of RAM pointer.
+; ldb (e) ; Preserve the value.
+; sta (e) ; Write the magic number to the current end of RAM.
+; cmp (e) ; Is the value in RAM, the same as the magic number we wrote?
+; bne @moveback ; No, so keep looping.
+; stb (e) ; Yes, so restore the previous value.
+;@end:
+; mov a, e ; Return the end of RAM pointer.
+; ple.q ; Restore E.
+; plb.q ; Restore B.
+; rts ; End of findramend.
+
+a
+.org findramend
+v
+q