diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2020-10-04 18:22:00 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2020-10-04 18:22:00 -0400 |
commit | ca8e2f93acc794b00464c5513956bd84de258913 (patch) | |
tree | 83153822fdea777bd11a8254c0e4bd87fe1d8350 /test | |
parent | 784ff59108b887e246b0f33ff696dfd981659ab2 (diff) |
- Added support for reading, and writing outside the
emulator's memory.
All reads outside of the emulator's memory give back
$/0xFF bytes, while all writes outside of the
emulator's memory are ignored.
- Implemented malloc(), and free() in the SuB Suite.
In order to do this, I had to add support for a heap,
which I did by reserving the first 3 banks of the
address space (the first 192K), and by adding a
routine that finds the end of the RAM.
In this case, I set the starting address for the
routine at bank 3 (bank 4 with one indexing), but,
the routine's starting address isn't hardcoded, and
thus, any starting address can be passed as an
argument.
The routine uses the fact that we can now read/write
outside the emulator's memory, and also uses the
fact that writing outside the emulator's memory will
be ignored, and that reading outside the emulator's
memory will always read $/0xFF bytes, and uses that
to signal that it's reached the end of the RAM.
- Added a test program for getting the size of RAM
starting at address $/0x20000.
Diffstat (limited to 'test')
-rw-r--r-- | test/getramsize.s | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/getramsize.s b/test/getramsize.s new file mode 100644 index 0000000..cd2c69b --- /dev/null +++ b/test/getramsize.s @@ -0,0 +1,45 @@ +; Find the end of RAM, and get the size of the RAM. +; Written by mr b0nk 500 <b0nk@b0nk.xyz>. + +RAMSTART = $20000 +MAGIC = $AA + +.org 0 +; End of RAM. +ptr1: + .res 8 + +.org $8000 +reset: + cps ; Boilerplate reset code. + ldx.w #$FFFF ; + txs ; + and #0 ; Reset A. + tax ; +start: + lda.d #RAMSTART ; Set the starting point of getramsize to the start of our RAM. + jsr getramsize ; Get the size of the RAM. + bra start ; + + +getramsize: + sta.q ptr1 ; Set the end of RAM pointer to the argument. + and #0 ; Reset A. + tab ; Reset B. + lda #MAGIC ; Set A to a magic number. +@loop: + sta (ptr1) ; Write the magic number to the current end of RAM. + cmp (ptr1) ; Is the value in RAM, the same as the magic number we wrote? + bne @end ; No, so we're done. + inc.q ptr1 ; Yes, so increment the end of RAM pointer. + inb ; Increment the byte count. + bra @loop ; Keep looping. +@end: + inc $0110 ; + rts ; End of getramsize. + +.org $FFC0 +.qword reset + +a +d |