473,378 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Fibonacci series 2005 (once more just for fun :) )

CII
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

Nov 14 '05 #1
12 2669
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, ....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.]


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 =----
Nov 14 '05 #2
CII


Mark McIntyre wrote:
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,

...
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.]


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, ---. :)
Nov 14 '05 #3
On Mon, 09 May 2005 23:24:50 +0100, Mark McIntyre
<ma**********@spamcop.net> wrote:
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,

...
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.]


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.


Well said!
--
auric underscore underscore at hotmail dot com
*****
The other two got to meet digestive juices. Worst consolation prize ever.
Nov 14 '05 #4
CII wrote:
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!


Assholes that crosspost to 6 newsgroups, especially when off-topic in at
least 5 of them, often fall back on this absurd defense. The answer is
not that we should ignore your antisocial antics; it is that you should
learn to behave.
Nov 14 '05 #5
Auric__ wrote:
On Mon, 09 May 2005 23:24:50 +0100, Mark McIntyre
<ma**********@spamcop.net> wrote:
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,

...

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.]

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.


Well said!

Good lord, people, is it really that big of a deal? Sure, I don't
particularly care to hear about the Fibonacci sequence written in any
other language than C (on this newsgroup) either but CII just wanted to
have a little fun. There's certainly no need for the language and
obscene comments; give it a rest.

Nov 14 '05 #6
On Tue, 10 May 2005 02:48:29 -0400, in comp.lang.c , "Justin M.
Goldberg" <go******@cse.ohio-state.edu> wrote:
Auric__ wrote:
On Mon, 09 May 2005 23:24:50 +0100, Mark McIntyre
<ma**********@spamcop.net> wrote:
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,
Flameproof underpants on.
Well said!

Good lord, people, is it really that big of a deal?


Almost as much of a big deal as posting html to text newsgroups.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>


so please turn off this bollocks when posting to comp.lang.c
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
Nov 14 '05 #7
CII


Mark McIntyre wrote:
On Tue, 10 May 2005 02:48:29 -0400, in comp.lang.c , "Justin M.
Goldberg" <go******@cse.ohio-state.edu> wrote:
Auric__ wrote:
On Mon, 09 May 2005 23:24:50 +0100, Mark McIntyre
<ma**********@spamcop.net> wrote:

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,
>
>
Flameproof underpants on.

Well said!

Good lord, people, is it really that big of a deal?


Almost as much of a big deal as posting html to text newsgroups.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>


so please turn off this bollocks when posting to comp.lang.c

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>


html? didn't realize I've using html, hmm..

Nov 14 '05 #8
CII


Martin Ambuhl wrote:

CII wrote:
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!


Assholes that crosspost to 6 newsgroups, especially when off-topic in at
least 5 of them, often fall back on this absurd defense. The answer is
not that we should ignore your antisocial antics; it is that you should
learn to behave.


Well I think that "crossposting" as it is is much better than the filth
you're typing as language. Mind my saying, you are the ones that need a
little re-educating (:)). Don't think I can't cuss too, it just isn't
part of my education. I never realized that posting a mathematical
matter to computer language groups was off topic you spods, specially
when it's an algorithm that may show a thing or two, regardless of the
"language" it is written in, after all mathematics is an universal
language and is a very important part of computer programming, or is it
antisocial too?

You should be grateful for different (possibly new) information. I
don't even read your newsgroups in case you haven't noticed, I just
thought I'd share something with all those involved (i.e., computer
programmers).

Nice way to learn and to improve yourself, to shut your brains, way to
go!
Nov 14 '05 #9
In article <42***************@laposte.net>, CII <x.***@laposte.net>
wrote:
You should be grateful for different (possibly new) information.


That's what spammers say as well. Please just stop your whining.
Jonas
Nov 14 '05 #10
CII <x.***@laposte.net> writes:
[snip]
Well I think that "crossposting" as it is is much better than the filth
you're typing as language.
Two points. First, in my opinion, your crossposting is worse that a
few naughty words. Second, it doesn't matter which is worse; someone
else's misbehavior (if that's what it is) doesn't excuse yours.
I never realized that posting a mathematical matter to computer
language groups was off topic [...]

Well, it is. I'm reading this in comp.lang.c, where we discuss the C
programming language as defined by the ANSI/ISO standards. This is a
high-volume group that's in constant danger of being overwhelmed by
off-topic posts. If we want to read about something other than C, we
go to other newsgroups.
You should be grateful for different (possibly new) information. I
don't even read your newsgroups in case you haven't noticed,

[...]

Perhaps that's why you didn't know that your article is off-topic.
It's considered rude to post to a newsgroup without knowing something
about it. Lurk for a little while, or browse the archives. Read the
FAQ. And if you have nothing to say that's topical for the newsgroup
to which you're posting, post somewhere else or don't post at all.

Followups redirected appropriately.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #11
CII


Keith Thompson wrote:

CII <x.***@laposte.net> writes:
[snip]
Well I think that "crossposting" as it is is much better than the filth
you're typing as language.
Two points. First, in my opinion, your crossposting is worse that a
few naughty words. Second, it doesn't matter which is worse; someone
else's misbehavior (if that's what it is) doesn't excuse yours.


"A few naughty words", so that's what you're about, but then of course
you said it yourself, it's your opinion.
I never realized that posting a mathematical matter to computer
language groups was off topic

[...]

Well, it is. I'm reading this in comp.lang.c, where we discuss the C
programming language as defined by the ANSI/ISO standards. This is a
high-volume group that's in constant danger of being overwhelmed by
off-topic posts. If we want to read about something other than C, we
go to other newsgroups.


In constant danger of being overwhelmed, whoa, freedom in danger!

You should be grateful for different (possibly new) information. I
don't even read your newsgroups in case you haven't noticed,

[...]

Perhaps that's why you didn't know that your article is off-topic.
It's considered rude to post to a newsgroup without knowing something
about it. Lurk for a little while, or browse the archives. Read the
FAQ. And if you have nothing to say that's topical for the newsgroup
to which you're posting, post somewhere else or don't post at all.

Followups redirected appropriately.


Well that's the thing, I know "something" about your groups, that didn't
include of course knowing about so many people with nothing better to do
than to be raged because of math!

/dev/null oh boy.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.

Nov 14 '05 #12
CII <x.***@laposte.net> wrote:
In constant danger of being overwhelmed, whoa, freedom in danger!


Usefulness and effectiveness in danger, rather. If there weren't a
need for focused groups, I'm sure Usenet could have done just fine
with a single group misc.talk.everything.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: dleecurt | last post by:
Hello, I have a small problem, I am trying to write a program that will calculate the Fibonacci number series, and I have the code complete with one problem. I used a long in to store the numbers,...
4
by: YS Sze | last post by:
If you know the exact longitude and latitude for a specific location, would anyone think it'd make any sense to find out if this set of location numbers is really part of the Fibonacci series or...
11
by: MARQUITOS51 | last post by:
Hey guys this is the fibonacci series. But Im having this huge problem. First of all I want to do the simplest code possible so then I can use user defined functions and arrays. But this one didnt...
22
by: kookai | last post by:
hi I need help with this problem. I have tried writting the program, i just can not get it to run properly. Please Write The Fibonacci series 0, 1, 1, 2, 3, 5, 8, 13, 21, ... begins with the...
4
by: student | last post by:
Hi guys, please tell me how to write the iterative version of fibonacci series using a stack. Thanks
8
by: srinpraveen | last post by:
I know to write a program to print the fibonacci series. But the problem is my teacher has asked us to write a program to print the natural numbers that are not involved in the fibonacci series. For...
3
by: greek | last post by:
Hi! I hav to generate fibonaaci series using recursion: 0,1,1,2,3,5,8,18,21... whr fibonacci(0)=0 fibonacci(1)=1 fibonacci(n)=fibonacci(n-1)+fibonacci(n-2) ive witten the code but having 2...
3
by: veeru | last post by:
Hi All, Can anyone tell about how to create a FIBONACCI series in VB.Net and C# Thanks in Advance, Veeru
6
by: deepner | last post by:
plz help to find why the program showing fibonacci(non-recursively) is running infinitely #include<iostream> #include<conio.h> using namespace std; unsigned int fibo(int a,int b) { unsigned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.