Closed maziac closed 5 years ago
page vs bank, my terminology may be wrong, but I'm trying consistently to call "bank" the 16kiB ZX128-like chunks of memory, consisting of two 8kiB "pages". RAM-extended Next board has thus "banks" 0..111 (112 banks = 112*16 = 1792kiB of RAM) and "pages" 0..223 (224 pages = 224*8 = 1792kiB) (non RAM-extended board has 48 banks = 96 pages = 768kiB RAM). So if you have "bank N", it consists of two consecutive pages [2*N, 2*N+1].
about paging: hm, checking the docs, the default slot of zxspectrum next is not specified, so JFYI it's slot 7, your PAGE 10
does flip the page 10 (8kiB page) into range $E000..$FFFF (slot 7). As you do org 0
for your code, you can pretty much page anything you wish, and it will never change the result. To change memory at $0000 you should do slot 0 : page 10
, or just mmu 0, 10
why bank 7: the default page mapping in the assembler is { 14, 15, 10, 11, 4, 5, 0, 1 }
(following the default ZX128 mapping {7, 5, 2, 0}
) ... i.e. in 16kiB bank numbers, you are modifying the bank 7 (page 14 in 8kiB pages terms), thus bank 7 is being stored into NEX file (it has non-zero content produced by that DEFB
).
more on banks: keep in mind the NEX file is loaded (on actual HW) into mapping {255, 255, 10, 11, 4, 5, <entryBank*2>, <entryBank*2+1>}
(with "entryBank" being by default 0, unless explicitly specified in SAVENEX OPEN as something else), so as long as you are working on initial code to be run right after NEX is loaded, there's no sense to operate in the $0000-$1FFF range, as there's ROM mapped initially. In this regard the NEX heritage from SNA shows up, put the init code probably at $8000 (must be page 4 then) or $C000 (can be page entryBank*2 or 0 by default) ($C000 in tandem with "entryBank" value allows you to not trash the sysvars immediately and start your NEX file from like bank 16, and preserve/init lower banks by your init code as you wish).
it still may make sense to do MMU 0, 20 : ORG 0 : someRoutineDesignedAt0000: nop
and it will be stored into NEX (it's Bank 10), and the machine code will be assembled as if being in address range starting at 0, but before executing the code like that, some other code of yours already running must map the bank 10 into slot 0, before jumping there.
about SAVENEX AUTO/BANK: these operate on the "1.75MiB" memory model, it doesn't matter what SLOT+PAGE config is currently set in the assembler, if you do SAVENEX BANK 30
, the two pages 60 and 61 of the virtual device memory are stored, with whatever content there currently is, it doesn't matter if your current paged-in memory directly accessible through ORG is {1, 2, 3, 4, 5, 6, 7, 8}.
So the usage pattern of SAVENEX is more like: use SLOT+PAGE (MMU) to modify whole device memory as you want, and then do SAVENEX AUTO
to store all of it. And layout your init code with regards to the snapshot-like initialo state, i.e. use rather entry point like $8000 or $C000. (your "0" is anyway "do not exec", so that's valid choice too, but value like $100 would just start some ROM gibberish).
You can also check the docs_example asm (maybe that will make some of this even clearer, or at least you can point at particular line/value and ask "wtf" :) ): https://github.com/z00m128/sjasmplus/blob/master/tests/docs_examples/s_savenex_examples.asm
How can I provide the correct information to the sources so that I create the assembly in the correct pages?
To create machine code in correct page, you need to use combination of SLOT+PAGE+ORG directives (or you can use the new MMU which is basically SLOT+PAGE fused into one, with extra options). So by MMU you page-in the desired page at desired memory range, and then with ORG and normal source you modify that page. Repeat that until you have all of the device memory set as desired, then do the SAVENEX
(which is not affected by current SLOT+PAGE values, as it is working directly with the device memory and all "bank" values in NEX file are the 16kiB banks numbers, so make sure you are using doubled values with PAGE/MMU, as those operate with 8kiB pages.
(but this is non-bug to me ... or if bug, then it's the device docs which are lacking, but I already asked you to pinpoint which parts are confusing in the issue #55, so I can try to improve on them .. for me it's all very clear, because I know the implementation and I fully understand how those "virtual device" of sjasmplus work, and how to use them, but you failed second time to grasp how it works, so the docs are probably crap, but I need more feedback why this happened to you and which part of docs fooled you)
OK, I got it now. I think the problem in my brain was that I didn't fully understood the "emulation" that is done in sjasmplus. I didn't get what the SLOT was used for. I thought you could directly set the PAGE and then the binary would be written there although this also didn't fully make sense. Now I think I understood: with the PAGE/SLOT or MMU command you somehow slide a window over the different banks also during assembly.
At least I now managed to create a NEX file the way I wanted :-)
Thanks for the explanations.
Hi,
I'm trying to use the NEX file format and the ZXSPECTRUMNEXT device but I somehow don't understand how this should work. I have been playing aroung with the page/slot parameters but it never saves the page that I intend to save.
Here is some source code.
The hex output of the produced nex file shows that page 7 has ben used.
It seems that no matter which PAGE I supply always bank 7 is used in the nex file.
How can I provide the correct information to the sources so that I create the assembly in the correct pages?
(SjASMPlus Z80 Cross-Assembler v1.13.3)