Created
September 14, 2019 11:05
-
-
Save jdesiloniz/0f804739da5160066ed5b5c2943ff9f7 to your computer and use it in GitHub Desktop.
Tests for writing/reading to IRAM in SVP/SSP1601 asm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SSP1601 tests for external memory access - PRAM | |
org 400 | |
test_writes_0: eor a, a | |
ldi st, 0030 # Set ST5/ST6 bits so PMs can act like that | |
ldi ext6, 8000 # Load address part1 for 0x1C8000 | |
ldi ext6, 001C # Load address part2 for 0x1C8000, no modifiers | |
ld ext0, - # Programming PM0 for writes | |
ldi ext0, 1010 # Writing 0x1010 to 0x1C8000 | |
ld -, ext1 # Programming PM1 to read from that address | |
ld a, ext1 # Actual read | |
cmpi a, 1010 # Is it the value we expected? | |
bra z=0, @test_failed | |
test_writes_1: eor a, a | |
ldi st, 0030 # Set ST5/ST6 bits so PMs can act like that | |
ldi ext6, 8000 # Load address part1 for 0x1C8000 | |
ldi ext6, 001C # Load address part2 for 0x1C8000, no modifiers | |
ld ext1, - # Programming PM1 for writes | |
ldi ext1, 1010 # Writing 0x1010 to 0x1C8000 | |
ld -, ext0 # Programming PM0 to read from that address | |
ld a, ext0 # Actual read | |
cmpi a, 1010 # Is it the value we expected? | |
bra z=0, @test_failed | |
test_writes_2: eor a, a | |
ldi st, 0030 # Set ST5/ST6 bits so PMs can act like that | |
ldi ext6, 8000 # Load address part1 for 0x1C8000 | |
ldi ext6, 001C # Load address part2 for 0x1C8000, no modifiers | |
ld ext2, - # Programming PM2 for writes | |
ldi ext2, 1010 # Writing 0x1010 to 0x1C8000 | |
ld -, ext3 # Programming PM3 to read from that address | |
ld a, ext3 # Actual read | |
cmpi a, 1010 # Is it the value we expected? | |
bra z=0, @test_failed | |
test_writes_3: eor a, a | |
ldi st, 0030 # Set ST5/ST6 bits so PMs can act like that | |
ldi ext6, 8000 # Load address part1 for 0x1C8000 | |
ldi ext6, 001C # Load address part2 for 0x1C8000, no modifiers | |
ld ext3, - # Programming PM3 for writes | |
ldi ext3, 1010 # Writing 0x1010 to 0x1C8000 | |
ld -, ext2 # Programming PM2 to read from that address | |
ld a, ext2 # Actual read | |
cmpi a, 1010 # Is it the value we expected? | |
bra z=0, @test_failed | |
test_writes_4: eor a, a | |
ldi st, 0000 # EXT4 should behave as a PM regardless of the ST register | |
ldi ext6, 8000 # Load address part1 for 0x1C8000 | |
ldi ext6, 001C # Load address part2 for 0x1C8000, no modifiers | |
ld ext4, - # Programming PM4 for writes | |
ldi ext4, 5050 # Writing 0x5050 to 0x1C8000 | |
ld -, ext4 # Programming PM3 to read from that address | |
ld a, ext4 # Actual read | |
cmpi a, 5050 # Is it the value we expected? | |
bra z=0, @test_failed | |
test_write_inc_1: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8000 | |
ldi ext6, 081C # Load address 0x1C8000 with auto-increment set to 1 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8001 | |
ldi ext6, 8001 | |
ldi ext6, 001C # Preparing a read to 0x1C8001 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8001 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_inc_2: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8000 | |
ldi ext6, 101C # Load address 0x1C8000 with auto-increment set to 2 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8002 | |
ldi ext6, 8002 | |
ldi ext6, 001C # Preparing a read to 0x1C8002 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8002 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_inc_4: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8000 | |
ldi ext6, 181C # Load address 0x1C8000 with auto-increment set to 4 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8004 | |
ldi ext6, 8004 | |
ldi ext6, 001C # Preparing a read to 0x1C8004 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8004 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_inc_8: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8000 | |
ldi ext6, 201C # Load address 0x1C8000 with auto-increment set to 8 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8008 | |
ldi ext6, 8008 | |
ldi ext6, 001C # Preparing a read to 0x1C8008 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8008 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_inc_16: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8000 | |
ldi ext6, 281C # Load address 0x1C8000 with auto-increment set to 16 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8010 | |
ldi ext6, 8010 | |
ldi ext6, 001C # Preparing a read to 0x1C8010 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8010 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_inc_32: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8000 | |
ldi ext6, 301C # Load address 0x1C8000 with auto-increment set to 32 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8020 | |
ldi ext6, 8020 | |
ldi ext6, 001C # Preparing a read to 0x1C8020 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8020 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_inc_128: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8000 | |
ldi ext6, 381C # Load address 0x1C8000 with auto-increment set to 128 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8080 | |
ldi ext6, 8080 | |
ldi ext6, 001C # Preparing a read to 0x1C8080 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8080 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_dec_1: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8001 | |
ldi ext6, 881C # Load address 0x1C8001 with auto-decrement set to 1 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8000 | |
ldi ext6, 8000 | |
ldi ext6, 001C # Preparing a read to 0x1C8000 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8000 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_dec_2: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8002 | |
ldi ext6, 881C # Load address 0x1C8002 with auto-decrement set to 2 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8000 | |
ldi ext6, 8000 | |
ldi ext6, 001C # Preparing a read to 0x1C8000 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8000 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_dec_4: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8004 | |
ldi ext6, 881C # Load address 0x1C8004 with auto-decrement set to 4 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8000 | |
ldi ext6, 8000 | |
ldi ext6, 001C # Preparing a read to 0x1C8000 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8000 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_dec_8: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8008 | |
ldi ext6, 881C # Load address 0x1C8008 with auto-decrement set to 8 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8000 | |
ldi ext6, 8000 | |
ldi ext6, 001C # Preparing a read to 0x1C8000 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8000 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_dec_16: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8010 | |
ldi ext6, 881C # Load address 0x1C8010 with auto-decrement set to 16 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8000 | |
ldi ext6, 8000 | |
ldi ext6, 001C # Preparing a read to 0x1C8000 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8000 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_dec_32: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8020 | |
ldi ext6, 881C # Load address 0x1C8020 with auto-decrement set to 32 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8000 | |
ldi ext6, 8000 | |
ldi ext6, 001C # Preparing a read to 0x1C8000 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8000 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_dec_128: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8080 | |
ldi ext6, 881C # Load address 0x1C8080 with auto-decrement set to 128 | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8000 | |
ldi ext6, 8000 | |
ldi ext6, 001C # Preparing a read to 0x1C8000 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8000 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_special_inc: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8000 | |
ldi ext6, 401C # Load address 0x1C8000 with special auto-increment set | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8001 | |
ldi ext6, 8001 | |
ldi ext6, 001C # Preparing a read to 0x1C8001 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8001 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
eor a, a | |
ldi st, 0030 | |
ldi ext6, 8001 | |
ldi ext6, 401C # Load address 0x1C8001 with special auto-increment set | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8021 | |
ldi ext6, 8021 | |
ldi ext6, 001C # Preparing a read to 0x1C8021 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8021 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
# Warning: Virtua Racing never uses this mode and it's a guessed assumption on this implementation | |
test_write_special_dec: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8002 | |
ldi ext6, C01C # Load address 0x1C8002 with special auto-decrement set | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8001 | |
ldi ext6, 8001 | |
ldi ext6, 001C # Preparing a read to 0x1C8001 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8001 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
eor a, a | |
ldi st, 0030 | |
ldi ext6, 8021 | |
ldi ext6, 401C # Load address 0x1C8021 with special auto-decrement set | |
ld ext0, - | |
ldi ext0, 1010 | |
ldi ext0, 2020 # This should be a write to 0x1C8001 | |
ldi ext6, 8001 | |
ldi ext6, 001C # Preparing a read to 0x1C8001 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8001 | |
cmpi a, 2020 | |
bra z=0, @test_failed | |
test_write_overwrite: eor a, a | |
ldi st, 0030 | |
ldi ext6, 8000 | |
ldi ext6, 001C # Load address 0x1C8000 | |
ld ext0, - | |
ldi ext0, 1010 # Write 0x1010 to 0x1C8000 | |
ldi ext6, 8000 | |
ldi ext6, 041C # Load address 0x1C8000 with overwrite mode | |
ld ext0, - # Reprogram EXT0 to pick up new settings | |
ldi ext0, 0FFF # Write 0xFFF to 0x1C8000 in overwrite mode | |
ldi ext6, 8000 | |
ldi ext6, 001C # Preparing a read to 0x1C8000 | |
ld -, ext0 | |
ld a, ext0 # Reading from 0x1C8000 | |
cmpi a, 1FFF #The upper nibble to be written was 0 so it should have been ignored | |
bra z=0, @test_failed | |
# Test finished: | |
bra always, @test_success | |
test_failed: bra always, @test_failed | |
test_success: bra always, @test_success |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment