Fibonacci系列2005(再一次只是为了好玩:)) [英] Fibonacci series 2005 (once more just for fun :) )
问题描述
大家好。我一直在阅读关于斐波那契
系列一年的帖子就在这个新闻组上,虽然它不是直接游戏
相关,我会我也分享了自己的笔记。
在另一个新闻组中,正在讨论着名的
斐波纳契序列,以及由海报写的精美程序我的
关注所以只是为了好玩我自己写了一个并且在两天前将它放在网上只是
。它可以在网站上找到
http://www.geocities .com / yssmlp
我喜欢我的程序是它既小又快,而且它是b / b
:这是207字节大,它处理近300,000个术语
并且速度非常快 - 它产生的前几千个术语在几秒钟内完成,我没有测量过它。
这不是(并且不是)我打算竞争试图制作
最佳斐波那契项目然而 - 巧合的是我发现原始海报的'b
比我的更好(更优雅)。我想要的是
而不仅仅是为了分析不同的
视角,从哪里看看着名的序列。
哦是的,它是用masm写的,对于dos,在2005年,用16位代码
未经优化:)(只是在开玩笑)
干杯。 br />
[我在几个小组上发帖,因为我确定他们中的某些人可能会对这个话题感兴趣,所以请耐心等待我,谢谢。]
这里是快速和好奇的代码:
..MODEL TINY
; ----------
;使用YSS(2005年5月)与FIBONACCI编号一起玩
;
; F(N + 2)= F(N + 1)+ F(N)
; F(0)= 0,F(1)= 1
;
; MAX TERMS =(60000 - LOG(SQR(5))/(LOG(1+) SQR(5)/ 2)))/(LOG(1 + SQR(5)/ 2))
; = 287090 APPROX。
;
;'60000'是可能数量的总数。
;
;本程序计算并输出''FIBONACCI'系列产品,以b / b
;约287000+条款。它不是很快:
;
; - 没有或没有优化(这个代码是'在飞行中'''
; - 数字的压缩:
;每个字节在LO-HI订单中包含两个Decimaal DIGITS,
;这需要额外的时间。
; - 每个数字输出一次只能输出一个。
;如果一个完整的字符串可以获得超过32%的速度增加
;是输出INSTEAD。
;
;
;使用两个累加器,X1和X2,每个都能够处理
60000
; DIGITS(30000 BYTES LONG EACH)。
;
;使用:
; SET TL = MAX#OF TERMS - >装配 - > F7可以看到STDOUT结果
;条款一次输出一行(结束0D 0A)
;
;
CSEG SEGMENT PARA PUBLIC''代码''
ORG 100H
ASSUME CS:CSEG,DS:CSEG
START:
X1 EQU 0
X2 EQU X1 + 30000
TL EQU 287000;计算总条款
MOV DI,OFFSET A + X1
MOV CX,60000/2
REP STOSW; CLR ALL
INC AX
MOV X1T,AX
MOV [A + X1],AX;
MOV BP,TL; TOTAL#TERMS [F(X)] CALC''D
S00:
MOV DI,OFFSET A + X2
MOV SI,OFFSET A + X1
TEST BL,1
JNE S001
XCHG DI,SI
S001:
CALL LOUT
ADD12:
PUSH DI
PUSH SI
PUSH BP >
XOR BP,BP
MOV CX,X1T
CLC
ACXMRE:
MOV AL,[DI]
MOV DL,[SI]
MOV AH,DL
PUSH AX
CALL AAB1
MOV DH,AL
POP AX
PUSHF >
SHR AX,1
SHR AX,1
SHR AX,1
SHR AX,1
POPF
CALL AAB1
PUSHF
AND DH,0FH
SHL AL,1 >
SHL AL,1
SHL AL,1
SHL AL,1
或者AL,DH
POPF
MOV [SI],AL
JNB ADOK
CMP CX,1
STC
JNE ADOK
INC CX
ADOK:
INC DI
INC SI
INC BP
LOOP ACXMRE
MOV X1T,BP
POP BP
POP SI
POP DI
DEC BL
DEC BP
JNE S00 < br $>
RET
LOUT:
MOV DX,X1T
PUSH DI
PUSH SI
MOV AH,2
MOV SI,DI
DEC SI
ADD DI,DX
MOV CX,000FEH; CH = 0用于领先0''不要用
LN0001:
MOV DL ,[DI]
TEST CL,1
JNE LN0000
SHR DL,1
SHR DL,1
SHR DL,1
SHR DL,1
JMP SHORT LN0002
LN0000:< br $>
DEC DI
LN0002:
AND DL,0FH
或者DL,30H
CMP DL,30H
JE LN00201
或CH,1
JMP LN0020
LN00201:
TEST CH,1
JE LN00202
LN0020:
INT 21H
LN00202:
DEC CL
CMP DI,SI
JNE LN0001
POP SI
POP DI
ODOAH:
MOV AH,9
MOV DX,OFFSET ODOAX
INT 21H
RET
ODOAX DB 13,10,36
AAB1:
PUSHF >
AND AX,0F0FH
POPF
ADC AL,AH
AAA
RET
AAA
RET
AAA
RET
AAA
RET
X1T DW 0; #DIGITS SO FAR
标签字>
; -------------------------------
; http://www.geocities.com/yssmlp
; pi * *****@hotmail.com
;或谷歌周围的yssmlp ! :)
; -------------------------------
CSEG结束
结束开始
Hi everybody. I''ve been reading posts a year old about the fibonacci
series right on this newsgroup, and while it''s not directly games
related, I''ll share my own notes as well.
On another newsgroup there is an ongoing discussion about the famous
fibonacci sequences, and a fine program written by a poster got my
attention so just for fun I wrote one myself and put it on the web just
about two days ago. It can be found on the site
http://www.geocities.com/yssmlp
What I like about my program is that it''s both small and fast, and it
makes a point: It''s 207 bytes large, it handles nearly 300,000 terms
and it is very fast- it yields the first thousand or so terms in a
couple of seconds, I haven''t measured it.
It is not (and it wasn''t) my intention to compete trying to make the
best fibonacci program yet -incidentally I find the original poster''s
attempt much better (much more elegant) than mine. What I wanted
instead was rather simply to have some fun analyzing a different
perspective from where to look at the famous sequence.
Oh yeah, and it''s written in masm, for dos, in 2005, in 16 bit code
unoptimized :) (just joking)
Cheers.
[I''m posting on several groups because I''m sure some people in them may
be interested in this topic, so please bear with me, Thank you.]
Here''s the code for the fast and the curious:
..MODEL TINY
;----------
;PLAYING WITH FIBONACCI NUMBERS BY YSS (MAY 2005)
;
;F(N+2)=F(N+1)+F(N)
; F(0)=0, F(1)=1
;
;MAX TERMS = (60000 - LOG(SQR(5))/(LOG(1+SQR(5)/2))) / (LOG(1+SQR(5)/2))
; = 287090 APPROX.
;
;WHERE ''60000'' IS THE TOTAL NUMBER OF POSSIBLE DIGITS.
;
;THIS PROGRAM CALCS AND OUTPUTS THE ''FIBONACCI'' SERIES TO STDOUT UP TO
;ABOUT 287000+ TERMS. IT''S NOT VERY FAST DUE TO:
;
; - NO OR LITTLE OPTIMIZATION (THIS CODE WAS WRITTEN ''ON THE FLY'')
; - THE COMPRESSION OF THE DIGITS:
; EACH BYTE HOLDS TWO DECIMAL DIGITS IN LO-HI ORDER,
; THAT TAKES A LITTLE EXTRA TIME.
; - EACH DIGIT IS OUTPUT TO STDOUT ONE AT A TIME.
; A SPEED INCREASE OF OVER 32% CAN BE GAINED IF A FULL STRING
; IS OUTPUT INSTEAD.
;
;
;TWO ACCUMULATORS ARE USED, X1 AND X2, EACH CAPABLE OF HANDLING UP TO
60000
;DIGITS (30000 BYTES LONG EACH).
;
;USE:
;SET TL = MAX # OF TERMS -> ASSEMBLE -> F7 TO SEE RESULTS TO STDOUT
;TERMS ARE OUTPUT ONE LINE AT A TIME (ENDED WITH 0D 0A)
;
;
CSEG SEGMENT PARA PUBLIC ''CODE''
ORG 100H
ASSUME CS:CSEG,DS:CSEG
START:
X1 EQU 0
X2 EQU X1 + 30000
TL EQU 287000 ;TOTAL TERMS TO CALC
MOV DI,OFFSET A+X1
MOV CX,60000/2
REP STOSW ;CLR ALL
INC AX
MOV X1T,AX
MOV [A+X1],AX ;
MOV BP,TL ;TOTAL # TERMS [ F(X) ] CALC''D
S00:
MOV DI,OFFSET A+X2
MOV SI,OFFSET A+X1
TEST BL,1
JNE S001
XCHG DI,SI
S001:
CALL LOUT
ADD12:
PUSH DI
PUSH SI
PUSH BP
XOR BP,BP
MOV CX,X1T
CLC
ACXMRE:
MOV AL,[DI]
MOV DL,[SI]
MOV AH,DL
PUSH AX
CALL AAB1
MOV DH,AL
POP AX
PUSHF
SHR AX,1
SHR AX,1
SHR AX,1
SHR AX,1
POPF
CALL AAB1
PUSHF
AND DH,0FH
SHL AL,1
SHL AL,1
SHL AL,1
SHL AL,1
OR AL,DH
POPF
MOV [SI],AL
JNB ADOK
CMP CX,1
STC
JNE ADOK
INC CX
ADOK:
INC DI
INC SI
INC BP
LOOP ACXMRE
MOV X1T,BP
POP BP
POP SI
POP DI
DEC BL
DEC BP
JNE S00
RET
LOUT:
MOV DX,X1T
PUSH DI
PUSH SI
MOV AH,2
MOV SI,DI
DEC SI
ADD DI,DX
MOV CX,000FEH ;CH=0 FOR LEADING 0''S NOT OUT
LN0001:
MOV DL,[DI]
TEST CL,1
JNE LN0000
SHR DL,1
SHR DL,1
SHR DL,1
SHR DL,1
JMP SHORT LN0002
LN0000:
DEC DI
LN0002:
AND DL,0FH
OR DL,30H
CMP DL,30H
JE LN00201
OR CH,1
JMP LN0020
LN00201:
TEST CH,1
JE LN00202
LN0020:
INT 21H
LN00202:
DEC CL
CMP DI,SI
JNE LN0001
POP SI
POP DI
ODOAH:
MOV AH,9
MOV DX,OFFSET ODOAX
INT 21H
RET
ODOAX DB 13,10,36
AAB1:
PUSHF
AND AX,0F0FH
POPF
ADC AL,AH
AAA
RET
AAA
RET
AAA
RET
AAA
RET
X1T DW 0 ;#DIGITS SO FAR
A LABEL WORD
;-------------------------------
;http://www.geocities.com/yssmlp
;pi******@hotmail.com
;or google around for "yssmlp" ! :)
;-------------------------------
CSEG ENDS
END START
推荐答案
On Sun,2005年5月8日15:57:02 -0700 ,在comp.lang.c,CII
< x。*** @ laposte.net>写道:
On Sun, 08 May 2005 15:57:02 -0700, in comp.lang.c , CII
<x.***@laposte.net> wrote:
大家好。我一直在阅读关于斐波那契系列的一年前关于这个新闻组的帖子,
....哦是的,它是用masm写的,对于dos,2005年, 16位代码
.... [我在几个小组发帖,因为我确定他们中的某些人可能会对这个话题感兴趣,所以请耐心等待,谢谢。 ]
Hi everybody. I''ve been reading posts a year old about the fibonacci
series right on this newsgroup, ....Oh yeah, and it''s written in masm, for dos, in 2005, in 16 bit code ....[I''m posting on several groups because I''m sure some people in them may
be interested in this topic, so please bear with me, Thank you.]
防爆内裤。
算法在CLC中是offtopic
Masm是offtopic in CLC。
当你向10个团体发帖时,没有''这个团体'
x-发布到疯狂无关的团体是疯了
承认你知道它的offtopic是侮辱
也许你的意思很好,但这很明显是愚蠢的。如果你真的有想要给人们展示的东西,那就把它贴出去吧。
-
Mark McIntyre
CLC常见问题< http://www.eskimo.com/~scs/C-faq/top.html>
CLC自述文件:< http:// www .ungerhu.com / jxh / clc.welcome.txt>
---- ==通过Newsfeeds.Com发布 - 无限制 - 未经审查 - 安全的Usenet新闻== ----
http://www.newsfeeds.com #1新闻组服务世界! 120,000多个新闻组
---- =东海岸和西海岸服务器农场 - 通过加密实现全隐私= ----
Flameproof underpants on.
Algorithms are offtopic in CLC
Masm is offtopic in CLC.
there is no ''this group'' when you x-post to ten groups
x-posting to wildly unrelated groups is insane
admitting you know its offtopic is insulting
Perhaps you meant well, but this was plain stupid. If you really have
something you want to show people, post it whre its topical.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Mark McIntyre写道:
Mark McIntyre wrote:
On Sun,2005年5月8日15:57:02 -0700,在comp.lang.c,CII
< x。*** @ laposte.net>写道:
On Sun, 08 May 2005 15:57:02 -0700, in comp.lang.c , CII
<x.***@laposte.net> wrote:
大家好。我一直在阅读关于斐波那契系列的一年的帖子,就在这个新闻组上,
Hi everybody. I''ve been reading posts a year old about the fibonacci
series right on this newsgroup,
...
...
哦是的,它是'用masm写的,for dos,2005年用16位代码
Oh yeah, and it''s written in masm, for dos, in 2005, in 16 bit code
...
...
[我在几个小组上发帖,因为我确定有些人他们可能会对这个话题感兴趣,所以请耐心等待,谢谢。]
[I''m posting on several groups because I''m sure some people in them may
be interested in this topic, so please bear with me, Thank you.]
隔爆内裤。
算法是offtopic在CLC中
当你向10个小组发帖时,没有''这个小组'
x-post发送到疯狂无关的群体是疯了
承认你知道它的offtopic是侮辱
也许你的意思很好,但这很明显是愚蠢的。如果你真的有想要向人们展示的东西,可以将它贴在主题上。
-
Mark McIntyre
CLC FAQ< http:// www .eskimo.com / ~scs / C-faq / top.html>
CLC自述文件:< http://www.ungerhu.com/jxh/clc.welcome.txt>
> ---- ==通过Newsfeeds.Com发布 - 无限制 - 未经审查 - 安全使用网新闻== ----
http://www.newsfeeds.com 世界排名第一的新闻组服务! 120,000多个新闻组
---- =东海岸和西海岸服务器农场 - 通过加密的总隐私= ----
Flameproof underpants on.
Algorithms are offtopic in CLC
Masm is offtopic in CLC.
there is no ''this group'' when you x-post to ten groups
x-posting to wildly unrelated groups is insane
admitting you know its offtopic is insulting
Perhaps you meant well, but this was plain stupid. If you really have
something you want to show people, post it whre its topical.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
意见各不相同。 非常不相关的群体你确定吗?
我是否承认这是一个偏离主题的问题吗?
这会是热门话题吗?
别介意任何这个,只是忽略这个帖子,它是'那简单!
干杯,---。 :)
Opinions vary. "Wildly unrelated groups" are you sure?
Did I "admit" it''s an off topic issue?
Whre would it be topical?
Never mind any of this and just ignore the post, it''s that simple!
Cheers, ---. :)
2005年5月9日星期一23:24:50 +0100,Mark McIntyre
< ma ****** ****@spamcop.net>写道:
On Mon, 09 May 2005 23:24:50 +0100, Mark McIntyre
<ma**********@spamcop.net> wrote:
On Sun,2005年5月8日15:57:02 -0700,在comp.lang.c,CII
< x。*** @ laposte。净>写道:
On Sun, 08 May 2005 15:57:02 -0700, in comp.lang.c , CII
<x.***@laposte.net> wrote:
大家好。我一直在阅读关于斐波那契系列的一年的帖子,就在这个新闻组上,
Hi everybody. I''ve been reading posts a year old about the fibonacci
series right on this newsgroup,
...
...
哦是的,它是'用masm写的,for dos,2005年用16位代码
Oh yeah, and it''s written in masm, for dos, in 2005, in 16 bit code
...
...
[我在几个小组上发帖,因为我确定有些人他们可能会对这个话题感兴趣,所以请耐心等待,谢谢。]
[I''m posting on several groups because I''m sure some people in them may
be interested in this topic, so please bear with me, Thank you.]
隔爆内裤。
算法是offtopic在CLC中
当你向10个小组发帖时,没有''这个小组'
x-post发送到疯狂无关的群体是疯了
承认你知道它的offtopic是侮辱
也许你的意思很好,但这很明显是愚蠢的。如果你真的有想要向人们展示的东西,可以将它贴在主题上。
Flameproof underpants on.
Algorithms are offtopic in CLC
Masm is offtopic in CLC.
there is no ''this group'' when you x-post to ten groups
x-posting to wildly unrelated groups is insane
admitting you know its offtopic is insulting
Perhaps you meant well, but this was plain stupid. If you really have
something you want to show people, post it whre its topical.
说得好!
-
auric强调下划线在hotmail dot com
*****
其他两个人必须遇到消化液。最糟糕的安慰奖。
Well said!
--
auric underscore underscore at hotmail dot com
*****
The other two got to meet digestive juices. Worst consolation prize ever.
这篇关于Fibonacci系列2005(再一次只是为了好玩:))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!