首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >6510使用CBM Studio的程序集-带有分支错误的页面边界

6510使用CBM Studio的程序集-带有分支错误的页面边界
EN

Stack Overflow用户
提问于 2021-07-04 21:07:48
回答 2查看 85关注 0票数 0

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

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

代码语言:javascript
复制
**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字节)的无效分支错误--这是代码的一部分……

代码语言:javascript
复制
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!       

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

EN

回答 2

Stack Overflow用户

发布于 2021-08-18 10:26:40

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

要修复它,您可以更改以下内容:

代码语言:javascript
复制
beq longShot
   ... // more than 127 bytes of code here...
longShot

变成这样:

代码语言:javascript
复制
bne +
    jmp longShot
+
   ... // more than 127 bytes of code here...
longShot

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

票数 1
EN

Stack Overflow用户

发布于 2021-08-01 15:39:35

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

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

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

代码语言:javascript
复制
    bne n
    jmp where_you_want_to_go
n:  ; label for the next instruction after the jump

而不是这个

代码语言:javascript
复制
    beq where_you_want_to_go
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68245018

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档