It is currently Tue Aug 14, 2018 10:59 am

 All times are UTC - 7 hours

 Page 1 of 1 [ 9 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: 目前在学习这些，有谁有源码或资料的发下，谢谢！Posted: Wed Jun 07, 2006 11:36 am

Joined: Tue May 30, 2006 10:11 am
Posts: 29

16位运算

......

rand:
CLC ; C=0
LDA \$6003 ; A=\$6003
ADC \$6004 ; A+=\$6004
STA \$6004 ; \$6004=A
ADC \$6005 ; A+=\$6005
STA \$6005 ; \$6005=A
ADC \$6006 ; A+=\$6006
STA \$6006 ; \$6006=A
CLC ; C=0
LDA \$6003 ; A=\$6003
ADC #\$27 ; A+=27
STA \$6003 ; \$6003=A
LDA \$6004 ; A=\$6004
ADC #\$59 ; A+=59
STA \$6004 ; \$6004=A
PHA ; A入栈
LDA \$6005 ; A=\$6005
ADC #\$41 ; A+=41
STA \$6005 ; \$6005=A
AND #\$7F ; A&=7F
TAX ; X=A
LDA \$6006 ; A=\$6006
ADC #\$31 ; A+=31
STA \$6006 ; \$6006=A
PLA ; A出栈
RTS

SRAM选上
\$6003
\$6004
\$6005
\$6006

Last edited by zgh4000 on Sun Jun 11, 2006 10:23 am, edited 2 times in total.

Top

 Post subject: Posted: Thu Jun 08, 2006 7:38 pm

Joined: Sat Nov 05, 2005 6:38 pm
Posts: 9
Location: china

Top

 Post subject: Posted: Fri Jun 09, 2006 8:08 pm

Joined: Tue May 30, 2006 10:11 am
Posts: 29
tpu wrote:

Last edited by zgh4000 on Fri Jun 09, 2006 9:40 pm, edited 2 times in total.

Top

 Post subject: Posted: Fri Jun 09, 2006 8:20 pm

Joined: Tue May 30, 2006 10:11 am
Posts: 29
16位运算

Top

 Post subject: Posted: Sun Jun 11, 2006 8:10 am

Joined: Sat Nov 05, 2005 6:38 pm
Posts: 9
Location: china

math.asm
--------8<----------------------------
Code:

.dataseg
;math
.public mtht0 .byte
.public mtht1 .byte
.public mtht2 .byte
.public mtht3 .byte
;result
.public mthr0 .byte
.public mthr1 .byte
.public mthr2 .byte
.public mthr3 .byte
.codeseg

.extrn str_addr : byte

;;
;; 24bitx8bit->24bit
;;    mtht[210] x a => mthr[210]
;;
.proc mul24x8

sta mtht3
txa
pha

lda #\$00
sta mthr0
sta mthr1
sta mthr2
tax

-:   lda #\$01
and mtht3
beq +

clc
lda mthr0
adc mtht0
sta mthr0
lda mthr1
adc mtht1
sta mthr1
lda mthr2
adc mtht2
sta mthr2

+:   cpx #\$07
beq +

clc
rol mtht0
rol mtht1
rol mtht2
clc
ror mtht3
inx
jmp -

+:   pla
tax
rts
.endp

;;
;; 24bit/16bit => 24bit,16bit
;;    mtht[210] / mthr[10] => mtht[210], mthr[32]
;;

.proc div24d16
txa
pha

lda #\$00
sta mthr2
sta mthr3
ldx #\$18

-:   clc
rol mtht0
rol mtht1
rol mtht2
rol mthr2
rol mthr3
bcs +

lda mthr3
cmp mthr1
bne +
lda mthr2
cmp mthr0
+:   bcc +
sec
lda mthr2
sbc mthr0
sta mthr2
lda mthr3
sbc mthr1
sta mthr3
lda mtht0
ora #\$01
sta mtht0

+:   dex
bne -

pla
tax
rts
.endp

;;
;; 24bit/8bit => 24bit,8bit
;;    mtht[210] / a => mtht[210], mtht[3]
;;
.proc div24d8
sta str_addr
txa
pha

lda #\$00
sta mtht3
ldx #\$18

-:   clc
rol mtht0
rol mtht1
rol mtht2
rol mtht3
lda mtht3
bcs ++
cmp str_addr
bcc +

++:   sec
sbc str_addr
sta mtht3
lda mtht0
ora #\$01
sta mtht0

+:   dex
bne -

pla
tax
rts
.endp

;;
;; 24bit+8bit => 24bit
;;    x[210] + a => x[210]
;;
.proc add24a8
clc
adc \$00,x
sta \$00,x
lda \$01,x
adc #\$00
sta \$01,x
lda \$02,x
adc #\$00
sta \$02,x
rts
.endp

;;
;; 24bit-8bit => 24bit
;;    x[210] - a => x[210]
;;
.proc sub24s8
sta str_addr
sec
lda \$00,x
sbc str_addr
sta \$00,x
lda \$01,x
sbc #\$00
sta \$01,x
lda \$02,x
sbc #\$00
sta \$02,x
rts
.endp

.public mul24x8, div24d8, div24d16, add24a8, sub24s8

Top

 Post subject: Posted: Sun Jun 11, 2006 9:50 am

Joined: Tue May 30, 2006 10:11 am
Posts: 29

Top

 Post subject: Posted: Sun Jun 11, 2006 6:48 pm

Joined: Sat Nov 05, 2005 6:38 pm
Posts: 9
Location: china

Top

 Post subject: Posted: Fri Jun 16, 2006 12:22 pm

Joined: Thu Jun 01, 2006 4:00 pm
Posts: 1
Will....... I really can not understand how NES works, it's just too complex.
I mean I can not manage asm will. so I tend to learn gameboy dev. Any way, the lay out of gameboy Ram is very similar as NES.

_________________
QQ: 19951460
MSN:jackll85@hotmail.com

Top

 Post subject: Posted: Fri Jun 16, 2006 1:54 pm

Joined: Tue May 30, 2006 10:11 am
Posts: 29
tpu wrote:

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 9 posts ]

 All times are UTC - 7 hours

#### Who is online

Users browsing this forum: No registered users and 1 guest

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

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki
Powered by phpBB® Forum Software © phpBB Group