Oh, I just noticed the “BANK0” is an ASCII char, not an integer. So, the
full ALT code would look more like this:

    LDA        BankNumMSG           ; read current bank number (ascii)
    INR        A                    ; add 1
    SUI        BANK0                ; convert ascii 'n' to n
    ANI        (NBANKS-1)           ; is it > highest valid bank number?
    MOV        B,A                  ; copy bank num to B
    MOV        C,A                  ; copy bank num to C
    MVI        A,PORT_CTL0          ; start with control port for bank 0
@LoopBN:
    JZ        @DoneBN               ; ANI above or DCR below set Z,
jump to commit
    ADI        BANK_CTL_OFFSET      ; add 4 to control port number
    DCR        B                    ; decrement B
    JMP        @LoopBN              ; loop
@DoneBN:
    STA        CtlPort              ; commit new control port number
    MOV        A,C                  ; get bank number
    ADI        BANK0                ; convert back to ascii character
    STA        BankNumMSG           ; commit new bank number display (ascii)

—b9

On Sun, May 24, 2026 at 11:48 PM B 9 <[email protected]> wrote:

> I’m no assembly expert, but at first glance at seeing the code, it seems
> odd to me that you’re allowing BANK0 to equal 1 sometimes in the follow
> stanza:
>
>
>     LDA        BankNumMSG                ; read current bank number (ascii)
>     INR        A                    ; add 1
>     CPI        BANK0+NBANKS                ; is it > highest valid bank 
> number?
>     JC        @UpdateBankNum                ; BankNum <= highest, jump to 
> commit
>     MVI        A,BANK0                    ; BankNum > highest, reset to '0'
> @UpdateBankNum:
>     STA        BankNumMSG                ; commit new bank number display 
> (ascii)
>
> If you stay with 0-based counting and NBANKS=4, I believe you can simply AND
> 0b0011 instead of doing the compare and jump. Something like this:
>
>
>     LDA        BankNumMSG                ; read current bank number (ascii)
>     INR        A                         ; add 1
>     AND        NBANKS-1                  ; Wrap back to 0 if it is > highest 
> valid bank number
>     STA        BankNumMSG                ; commit new bank number display 
> (ascii)
>
> Of course, even if I’m right, your original code is more flexible. For
> example, my shortcut would break if you wanted to compile for a situation
> where NBANKS is not a power of two. (I don’t know anything about RAM100,
> but I noticed that the two values for NBANKS mentioned were “2” and “4”).
>
> —b9
>
> On Sat, May 23, 2026 at 3:31 PM Brian K. White <[email protected]>
> wrote:
>
>>
>> I've been working on RAM100.CO to make usable assembly source from a
>> disassembly so I can add support for more than 2 banks and maybe port to
>> kc85, EU, make a common 100/200 source, etc.
>>
>> I've gotten the 100 version working and added the support for 4 banks.
>> So now for 100 & 102, all 1M of MiniNDP is usable for files.
>> (not just 102 because I have an untested dip-40 pcb for 100 & kc85)
>> I haven't started on 200 yet.
>>
>> 2 questions:
>>
>> Is there a less convoluted way to do the ALT version of this chunk of
>> code highlighted below? I feel like there must be a more direct way to
>> arrange that loop without a jump at both the beginning and end.
>>
>> Am I being silly even caring about it?
>> Both versions work fine and there's no speed or size problem.
>> I've scavenged enough bytes elsewhere that even the larger version
>> still comes out actually one byte shorter than the original binary
>> before padding just to make the bootstrap basic code with hard-coded top
>> & end values for the old binary also work on the new binary.
>>
>>
>> https://github.com/bkw777/NODE_DATAPAC/blob/main/software/RAMDSK/RAM100/4-bank/RAM100.S85#L929-L993
>>
>> What the chunk does is increment or roll-over 2 values.
>>
>> display bank number ascii '0' to '3'
>> control port number 129 to 141 step 4
>>
>> One defensible functional difference I just realized is with the alt
>> version I could have a hot key or call target for basic to jump directly
>> to any arbitrary bank rather than stepping through a loop.
>>
>> --
>> bkw
>>
>>

Reply via email to