如何在 6502 程序集中读取从 $0200 到 $05ff 的网格

How to read a grid from $0200 to $05ff in 6502 Assembly

所以我得到了一项作业,我们必须使用 6502 汇编仿真器使用彩色像素制作符号。我不太明白这个网格是如何工作的。有人可以解释一下这个网格是如何工作的,也许可以举个例子吗?

这里是 link 到模拟器:https://skilldrick.github.io/easy6502/#first-program

以及我要使用的网格:https://i.stack.imgur.com/QuqPi.png

我认为迈克尔的命令是正确的;由于潜在的寄存器歧义原因,避免使用 'x' 和 'y',地址 00 + (q*32) + p 包含(p,q)处的像素,p 和 q 在 0 到 31 范围内,并且在每个字节中低四位决定像素颜色。

例如00是左上角的像素,01是左上角右边第一个像素,20是左上角下面的一个像素。

在 6502 术语中,通用 plot 子例程的一种可能的直接实现可以使用索引间接寻址,将 00 + (q*32) 存储到零页位置,然后通过 p 进行索引以命中特定的水平位置在那一行之内。在我的头脑中,没有检查汇编程序使用的语法和硬编码零页地址 $80 和 $81 的使用:

; 
; Plot; stores the colour in A to the pixel at (y, x).
; So, yes: x and y are backwards.
;
; Clobbers x.
;
Plot:
    ; Arbitrarily, this adds x to (0 >> 5) and
    ; then shifts the whole lot left by 5. That's
    ; rather than shifting x by 5 and then doing a
    ; one-byte add to the upper byte, I guess.

    pha
    txa
    clc
    adc # ;  = 0 >> 5
    sta 
    lda #[=10=]
    sta 

    ; Multiply by 32. You could unroll this if
    ; that's what your priorities imply.
    ldx #5
.rollLoop
    asl 
    rol 
    dex
    bne rollLoop

    pla
    sta (), y

    rts