It is currently Fri Nov 17, 2017 4:19 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: DATA COPY
PostPosted: Mon Jun 12, 2017 3:22 am 
Offline

Joined: Fri Jun 02, 2017 2:45 am
Posts: 7
Code:
;[FC][数据复制]
;FlameCyclone 2017.6.11

 .ORG $D000

COPY_FROM_L = $40
COPY_FROM_H = $41
COPY_TO_L = $42
COPY_TO_H = $43


COPY_DATA:
 PHA
 TXA
 PHA
 TYA
 PHA
 LDX #$00
 LDY #$00
COPY_TO_SET:   ;目的开始地址设置
 LDA COPY_TO_ADDR+1
 STA COPY_TO_L
 LDA COPY_TO_ADDR
 STA COPY_TO_H

COPY_FROM_SET:   ;数据源开始地址设置
 LDA COPY_FROM_ADDR+1
 STA COPY_FROM_L
 LDA COPY_FROM_ADDR
 STA COPY_FROM_H
 
COPY_START:   ;复制开始
 LDA COPY_TO_L
 CMP COPY_OVER_ADDR+1
 BNE COPY_DATA_START
 LDA COPY_TO_H
 CMP COPY_OVER_ADDR
 BEQ COPY_OVER
COPY_DATA_START:   ;开始复制数据
 LDA (COPY_FROM_L),Y
 STA (COPY_TO_L),Y
 JSR COPY_TO_ADD
 JSR COPY_FROM_ADD
 JMP COPY_START

COPY_OVER:    ;结束数据复制
 LDA (COPY_FROM_L),Y
 STA (COPY_TO_L),Y
 PLA
 TAY
 PLA
 TAX
 PLA
 RTS
 
COPY_FROM_ADD:    ;原地址递增
 INC COPY_FROM_L
 BNE COPY_FROM_ADD_RTS
 INC COPY_FROM_H
COPY_FROM_ADD_RTS:
 RTS
 
COPY_TO_ADD:    ;目的地址递增
 INC COPY_TO_L
 BNE COPY_TO_ADD_RTS
 INC COPY_TO_H
COPY_TO_ADD_RTS:
 RTS

COPY_FROM_ADDR:    ;数据源开始地址
 .DB $C0,$00
COPY_TO_ADDR:    ;目的开始地址
 .DB $60,$00
COPY_OVER_ADDR:    ;目的结束地址
 .DB $7F,$FF


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group