1

我现在关心的一个问题是制作一些汇编语言子例程,这些子例程需要从 C 程序中调用,以便在 LCD 屏幕上进行 CountRoutes、FindRoutes 或 DisplayRoutes。例如,这是我保存路由地址的代码,对于第一个子例程 CountRoutes,它应该在找到 -1 并停止计数之前计算我在内存中有多少条路由。

这是我到目前为止所做的,但它不起作用。我需要改变的是:忽略 .byte 空行(跳转到下面的两个字符串),验证你是否在字符串的末尾(满足 0)并再次跳转直到你找到另一个 .word 6 或 -1。

            .word  4
            .byte  null
            .asciz "Dee Bridge"
            .asciz ""

            .word  5
            .byte  'x
            .asciz "Echt Terminus"
            .asciz "Express"

            .word  -1              ; route 0xffff terminates the data set

.area   text

_RouteCount::
            pshx
            tfr     d,y         ;
            ldx     #0          ; Clear index
Loop:       ldab    1,y+        ; Fetch next character; inc Y
            bmi     Done        ; If -1 is found, exit loop
            bra     Loop        ; Repeat loop 
            ldx     #1          ; Store no match flag in X
            beq
            bra     Loop
Done:       tfr     Y,D         ; Transfer index in D
            pulx
            rts   
4

0 回答 0