本文介绍了如何在MOS 6502的ASM中创建延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是ASM新手,我正在尝试解决如何为以下代码创建延迟:
org $1000
loop: inc $d021
jmp loop
推荐答案
我想注释已经足够清楚了。
每帧(1/50秒)更改颜色的代码示例
sei ; enable interrupts
loop1: lda #$fb ; wait for vertical retrace
loop2: cmp $d012 ; until it reaches 251th raster line ($fb)
bne loop2 ; which is out of the inner screen area
inc $d021 ; increase background color
lda $d012 ; make sure we reached
loop3: cmp $d012 ; the next raster line so next time we
beq loop3 ; should catch the same line next frame
jmp loop1 ; jump to main loop
每秒更改颜色的代码示例
counter = $fa ; a zeropage address to be used as a counter
lda #$00 ; reset
sta counter ; counter
sei ; enable interrupts
loop1: lda #$fb ; wait for vertical retrace
loop2: cmp $d012 ; until it reaches 251th raster line ($fb)
bne loop2 ; which is out of the inner screen area
inc counter ; increase frame counter
lda counter ; check if counter
cmp #$32 ; reached 50
bne out ; if not, pass the color changing routine
lda #$00 ; reset
sta counter ; counter
inc $d021 ; increase background color
out:
lda $d012 ; make sure we reached
loop3: cmp $d012 ; the next raster line so next time we
beq loop3 ; should catch the same line next frame
jmp loop1 ; jump to main loop
这篇关于如何在MOS 6502的ASM中创建延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!