Rev 539 | Blame | Compare with Previous | Last modification | View Log | Download
# file opened: mmu.asm1 0000 ; DOCS design (happened here, while working on it):2 0000 ;3 0000 ; MMU <first slot number> [<last slot number>|<single slot option>], <page number>4 0000 ;5 0000 ; Maps memory page(s) to slot(s), similar to SLOT + PAGE combination, but allows to set up6 0000 ; whole range of consecutive slots (with consecutive memory pages). Or when only single7 0000 ; slot is specified, extra option can be used to extend particular slot functionality.8 0000 ; The slot behaviour will stay set in the current DEVICE until reset by another MMU9 0000 ; specifying same slot (even as part of range, that will clear the option to "default").10 0000 ;11 0000 ; Single slot option (default state is: no error/warning and no wrap = nothing special):12 0000 ; e = error on writing beyond last byte of slot13 0000 ; w = warning on writing beyond last byte of slot14 0000 ; n = wrap address back to start of slot, map next page15 0000 ;16 000017 0000 DEVICE NONE ; set "none" explicitly, to avoid "global device" featuremmu.asm(18): warning: MMU is allowed only in real device emulation mode (See DEVICE)18 0000 MMU ;; warning about non-device mode19 0000 DEVICE ZXSPECTRUM12820 000021 0000 ;; error messages (parsing test)mmu.asm(22): error: [MMU] First slot number parsing failed: MMU !22 0000 MMU !mmu.asm(23): error: [MMU] Second slot number parsing failed: MMU 123 0000 MMU 1mmu.asm(24): error: [MMU] Second slot number parsing failed: MMU 1 !24 0000 MMU 1 !mmu.asm(25): warning: [MMU] Unknown slot option (legal: e, w, n): xmmu.asm(25): error: [MMU] Comma and page number expected after slot info: MMU 1 x25 0000 MMU 1 x ; white space (or comma) after char to detect it as unknown optionmmu.asm(26): warning: [MMU] Unknown slot option (legal: e, w, n): x,mmu.asm(26): error: [MMU] Page number parsing failed: MMU 1 x,26 0000 MMU 1 x,mmu.asm(27): error: [MMU] Comma and page number expected after slot info: MMU 1 127 0000 MMU 1 1mmu.asm(28): error: [MMU] Page number parsing failed: MMU 0,28 0000 MMU 0,mmu.asm(29): error: [MMU] Page number parsing failed: MMU 0 1,29 0000 MMU 0 1,mmu.asm(30): error: [MMU] Page number parsing failed: MMU 0 e,30 0000 MMU 0 e,mmu.asm(31): error: [MMU] Page number parsing failed: MMU 0 e,!31 0000 MMU 0 e,!32 000033 0000 ;; correct syntax, invalid argumentsmmu.asm(34): error: [MMU] Requested page(s) must be in range 0..734 0000 MMU 0,8mmu.asm(35): error: [MMU] Slot number(s) must be in range 0..3 (or exact starting address of slot) and form a range35 0000 MMU 4,0mmu.asm(36): error: [MMU] Slot number(s) must be in range 0..3 (or exact starting address of slot) and form a range36 0000 MMU 3 4,0mmu.asm(37): error: [MMU] Requested page(s) must be in range 0..737 0000 MMU 0 0,8mmu.asm(38): error: [MMU] Slot number(s) must be in range 0..3 (or exact starting address of slot) and form a range38 0000 MMU 1 0,0mmu.asm(39): error: [MMU] Requested page(s) must be in range 0..739 0000 MMU 0 2,6 ; map pages 6, 7, 8 -> 8 is wrong40 000041 0000 ;; test functionality42 0000 ; set init markers in pages 0, 5, 6 and 743 0000 37 37 DB "77"43 0002 ORG 0xC00043 C000 30 30 DB "00"43 C002 ORG 0xC000, 543 C000 35 35 DB "55"43 C002 ORG 0xC000, 643 C000 36 36 DB "66"44 C002 PAGE 744 C002 ASSERT {0xC000} == "77"44 C002 PAGE 644 C002 ASSERT {0xC000} == "66"45 C002 PAGE 545 C002 ASSERT {0xC000} == "55"45 C002 PAGE 045 C002 ASSERT {0xC000} == "00"46 C00247 C002 ; test simple page-in48 C002 MMU 0, 548 C002 ASSERT {0} == "55"49 C002 MMU 1 3, 549 C002 ASSERT {0x4000} == "55"49 C002 ASSERT {0x8000} == "66"49 C002 ASSERT {0xC000} == "77"50 C00251 C002 ;; test slot options (these are confined to single slot only, not to range)52 C002 ; error option (guarding machine code write outside of current slot)53 C002 MMU 1 e, 553 C002 ASSERT {0x4000} == "55"54 C002 ORG 0x7FFFmmu.asm(54): error: Write outside of memory slot: 3276854 7FFF 36 73 ld (hl),'s' ; should be error, 2B opcode leaving slot memory55 8001 ASSERT {0x8000} == "6s" ; but damage is done in the virtual memory, that's how it is56 8001 ; while escaping from slot through ORG should be legal57 8001 ORG 0x7FFF57 7FFF 00 nop57 8000 ORG 0x800057 8000 36 36 DB "66"58 8002 ; changing page within tainted slot will keep the guarding ON59 8002 SLOT 159 8002 PAGE 659 8002 ASSERT {0x4000} == "66" ; map page 6 also into slot 160 8002 ORG 0x7FFFmmu.asm(60): error: Write outside of memory slot: 3276860 7FFF 36 73 ld (hl),'s'60 8001 ASSERT {0x8000} == "6s" ; error + damage check61 800162 8001 ; verify clearing option by another MMU63 8001 MMU 1, 563 8001 ASSERT {0x4000} == "55"64 8001 ORG 0x7FFF64 7FFF 36 36 ld (hl),'6'64 8001 ASSERT {0x8000} == "66" ; no error65 800166 8001 ; warning option (guarding machine code write outside of current slot)67 8001 MMU 1 w, 567 8001 ASSERT {0x4000} == "55"68 8001 ORG 0x7FFFmmu.asm(68): warning: Write outside of memory slot68 7FFF 36 73 ld (hl),'s' ; should be warning, 2B opcode leaving slot memory69 8001 ASSERT {0x8000} == "6s" ; but damage is done in the virtual memory, that's how it is70 8001 ; while escaping from slot through ORG should be legal71 8001 ORG 0x7FFF71 7FFF 00 nop71 8000 ORG 0x800071 8000 36 36 DB "66"72 8002 ; changing page within tainted slot will keep the guarding ON73 8002 SLOT 173 8002 PAGE 673 8002 ASSERT {0x4000} == "66" ; map page 6 also into slot 174 8002 ORG 0x7FFFmmu.asm(74): warning: Write outside of memory slot74 7FFF 36 73 ld (hl),'s'74 8001 ASSERT {0x8000} == "6s" ; warning + damage check75 800176 8001 ; verify clearing option by another MMU when the slot is part of range77 8001 MMU 0 2, 577 8001 ASSERT {0x4000} == "6s"78 8001 ORG 0x7FFF78 7FFF 36 37 ld (hl),'7'78 8001 ASSERT {0x8000} == "77" ; no warning79 800180 8001 ; next option making the memory wrap, automatically mapping in next page81 8001 MMU 1 n, 282 8001 ORG 0x400082 4000 6E 6E 6E... BLOCK 3*16384, 'n' ; fill pages 2, 3 and 4 with 'n'83 4000 ASSERT {0x4000} == "55" && {0x8000} == "77" ; page 5 is mapped in after that block84 4000 SLOT 1 ; verify the block write85 4000 PAGE 285 4000 ASSERT {0x4000} == "nn"86 4000 PAGE 386 4000 ASSERT {0x4000} == "nn"87 4000 PAGE 487 4000 ASSERT {0x4000} == "nn"88 400089 4000 ; do the wrap-around test with instructions, watch labels land into different pages90 4000 MMU 1 n, 491 4000 ORG 0x7FFE92 7FFE 37 label0_p4: scf93 7FFF 37 label1_p4: scf94 4000 35 35 label2_p5: db "55" ; "55" ; first two bytes of page 595 4002 73 73 73... BLOCK 16381, 's' ; leaves last byte of page 5 unfilled96 7FFF 31 36 36 label3_p5: ld sp,"66" ; '166' ; last byte of page 5, first two bytes of page 697 4002 ASSERT $ == 0x4002 && $$ == 698 4002 PAGE 498 4002 ASSERT {0x7FFE} == "77"99 4002 PAGE 599 4002 ASSERT {0x4000} == "55" && {0x4002} == "ss" && {0x7FFE} == "1s"100 4002 PAGE 6100 4002 ASSERT {0x4000} == "66"101 4002102 4002 LABELSLIST "mmu.lbl"103 4002104 4002 ;-----------------------------------------------------------105 4002 ; new part to test the optional third <address> argument106 4002 ; syntax errorsmmu.asm(107): error: [MMU] address parsing failed: MMU 0 e,0,107 4002 MMU 0 e,0,mmu.asm(108): error: [MMU] address parsing failed: MMU 0 e,0,!108 4002 MMU 0 e,0,!mmu.asm(109): error: Unexpected: ,109 4002 MMU 0 e,0,0,110 0000111 0000 ; valid syntax with address -exercise different code-paths112 0000 ORG 0x1234113 1234 MMU 0, 0, 0x4000114 4000 ASSERT 0x4000 == $ && 6 == $$ && {0x0000} == "00" && {$} == "66"mmu.asm(115): warning: value 0x12345 is truncated to 16bit value: 0x2345115 4000 MMU 0, 5, 0x12345 ; warning about truncating the address116 2345 ASSERT 0x2345 == $ && 5 == $$117 2345 DISP 0x8765mmu.asm(118): warning[displacedorg]: ORG-address set inside displaced block, the physical address is not modified, only displacement address118 8765 MMU 0, 7, 0x1234119 1234 ASSERT 0x1234 == $ && 7 == $$120 1234 MMU 0, 6, 0x3456 ; displacedorg-ok - suppress warning about ORG inside DISP121 3456 ASSERT 0x3456 == $ && 6 == $$122 3456 ENT123 2345 ASSERT 0x2345 == $ && 6 == $$124 2345# file closed: mmu.asmValue Label------ - -----------------------------------------------------------0x7FFE X label0_p40x7FFF X label1_p40x4000 X label2_p50x7FFF X label3_p5