1

当我运行我的程序时,我遇到了错误页面边界。在适用于 Windows 10 的 CBM prg studio 应用程序的任何帮助中,它都没有解释我如何增加这个边界,或者我需要做什么来避免这些错误。

它发生在基于标签 E1cycle 和 E2cycle 内的第 110 行和第 127 行的同一条指令上......


**Line 110:** BEQ space2reset     ; branch/jump if the result in A is 0

**Line 127:** BEQ space2reset     ; branch/jump if the result in A is 0

The errors...
**Line 110**:Page boundary crossed.   -   F:\C64\UltimateTests\test.asm

**Line 127**:Page boundary crossed.   -   F:\C64\UltimateTests\test.asm

[Error] Line 72:Invalid branch (200 bytes) "BEQ Name2    ; if we find it we branch using BEQ to name2 for msg2 "

[Error] Line 143:Invalid branch (-275 bytes) "BEQ StartBlackOut"

此外,正如您在上面看到的,我收到了这些奇怪的(200 字节)和(-275 字节)无效的分支错误——这是代码部分......

getnameb
        jsr $FF9F   ;SCNKEY, place ASCII character into keyboard queue
        jsr $FFE4   ;GETIN, this places the ASCII value into the Accumulator 

        BEQ getnameb ;loop until keys are pressed. (Branch if equal to zero)
        
        JSR $FFD2    ; CHROUT, print it to the screen as it is being typed in.
        CMP #13      ; CMP looks for the carrige return
        BEQ Name2    ; if we find it we branch using BEQ to name2 for msg2 
        
        CMP #32         ; Looking for space bar. If true error 1 is returned
        BEQ ErrorInput1

        ldx $0900    ; load into x the value at $0900 - replace what was there from JSRs
        STA $0019,x  ; also store what is being typed in consecutively? 
        INX          ; X IS INCREASED BY 1.
        stx $0900    ; Store X back to $0900, avoid being molested by the above JSRs
                     ; The value at $0900 is the length of the string!
        
        LDA $0900        ; Load into A the current length of the string 
        CMP #08          ; Looking for max 8 chars. If true error 2 is returned
        BEQ ErrorInput2
        
        JMP getnameb     ; if we don't we loop! 


;PRINT ERRORS 1 OR 2

;-----1
ErrorInput1   
        LDX #00       ; load into the x registry zero


E1cycle  
        LDA E1msg,x    ; load into A the E1msg, the x sequence.
        CMP #00        ; compare memory and accumulator to the value 0?    
        BEQ space2reset     ; branch/jump if the result in A is 0
        STA 1424,x     ; where on the screen does E1msg start?
        INX            ; inc x to move the print along 1 space?
        
        JMP E1cycle    ; jump back to the beginning of cycle and do it all again.

E1msg   text 'ERROR: NO SPACES PERMITTED - SPACE TO RESET'
        byte 0
;-----2

ErrorInput2  
        LDX #00       ; load into the x registry zero


E2cycle  
        LDA E2msg,x    ; load into A the E1msg, the x sequence.
        CMP #00        ; compare memory and accumulator to the value 0?    
        BEQ space2reset     ; branch/jump if the result in A is 0
        STA 1424,x     ; where on the screen does E1msg start?
        INX            ; inc x to move the print along 1 space?
        
        JMP E2cycle    ; jump back to the beginning of cycle and do it all again.

E2msg   text 'ERROR: MAX 8 CHARACTERS PERMITTED - SPACE TO RESET'
        byte 0

space2reset    
        jsr $FF9F   ;SCNKEY, place ASCII character into keyboard queue
        jsr $FFE4   ;GETIN, this places the ASCII value into the Accumulator 

        BEQ space2reset ;loop until keys are pressed. (Branch if equal to zero)
        
        CMP #32
        BEQ StartBlackOut ; Go to the very beginning of the programming and reset the whole thing!       

我需要用非常简单的术语向我解释这一点,因为我仍在学习,并且有时发现行话有点难以理解。谢谢!

4

2 回答 2

1

每条指令都占用一定数量的字节(查看每条指令的参考以了解更多信息)。例如,LDA nnnn 占用 3 个字节。因此,在使用相对分支(beq、bcs、bcc 等)而不是绝对跳转 (jmp) 的情况下,程序计数器 (PC) 只能在页面内跳转,即在 -128 到 127 字节的范围内(从 128 字节向后到 127 字节向前)。

要修复它,您可以更改它:

beq longShot
   ... // more than 127 bytes of code here...
longShot

进入:

bne +
    jmp longShot
+
   ... // more than 127 bytes of code here...
longShot

值得一提的是,一些汇编编译器,例如 64tass 支持长分支。如果它超出该范围,它将自动将相对分支编译为绝对。我不使用此选项,因为我更喜欢自己控制它。

于 2021-08-18T10:26:39.667 回答
0

当我运行我的程序时,我遇到了错误页面边界。在适用于 Windows 10 的 CBM prg studio 应用程序的帮助中,没有任何地方可以解释我如何增加这个边界,或者我需要做什么来避免这些错误。

您可能不会增加边界,这是硬件限制。相反,您应该确保条件分支的目标(即跳转到的位置)离分支指令本身不太远。换句话说,分支指令不能跳转到太远的目的地。(太远意味着相隔 128 个字节或更多)。

解决此问题的方法可能是重新排列代码,使目标更接近分支指令。但如果做不到这一点,你可以这样做:

    bne n
    jmp where_you_want_to_go
n:  ; label for the next instruction after the jump

而不是这个

    beq where_you_want_to_go
于 2021-08-01T15:39:34.820 回答