hi guys i've got a simple problem with fibonacci sequence.. I use tasm and my processor is amd

and this, so far, is my code:

``````.model small
.stack
.code
org 100h

start:

mov ah, 02h
mov cx, 07h

mov bl, 31h
mov dl, 30h

int 21h

inc dl
loop A

int 27h

end``````

it would just display the ascending order of 0-7 but not the fibonacci..
any help pls.

line 15 suppose to be;

``A:    add dl, bl``

If you are JUST trying to print 0-7 (as the start), you can remove the add.
Also you only need to increment the value in DL.
I also changed the last interrupt.

``````;-------------------80x86-------------------------
; 9-Aug-2011 - THINES01
; Compiled with A86 (http://eji.com/a86/)
; ------------------------------------------------

start:
mov ah, 02h
mov cx, 08h	; 0-7 is 8 chars/digits
mov dl, 30h	; character based zero
A:
int 21h		; print first char/digit
inc dl		;
loop A		; loop until CX is zero

int 20h		; drop to dos``````

If you are JUST trying to print 0-7 (as the start), you can remove the add.
Also you only need to increment the value in DL.
I also changed the last interrupt.

thines01, he is trying to make a Fibonacci sequence something like;
1, 1, 2, 3, 5, 8, 13 ...

So I think he should stick to my advice ;)

commented: Now i understand what you mean... +4

.text

fibonacci:

sw \$s0,0(\$sp)
sw \$a0,4(\$sp)
sw \$ra,8(\$sp)
sw \$s1,12(\$sp)
sw \$s2,16(\$sp)

move \$s0,\$a0

blt \$s0,2, end_basecase

subu \$a0,\$s0,1
jal fibonacci

move \$s1,\$v0
subu \$a0,\$s0,2
jal fibonacci
move \$s2,\$v0
b end

end_basecase:
li \$v0,1

end:
lw \$s0,0(\$sp)
lw \$a0,4(\$sp)
lw \$ra,8(\$sp)
lw \$s1,12(\$sp)
lw \$s2,16(\$sp)
jr \$ra

main:
la \$a0,input_request
li \$v0,4
syscall

li \$v0,5
syscall

move \$a0,\$v0

jal fibonacci

move \$t0,\$v0

la \$a0,result
li \$v0, 4
syscall
move \$a0,\$t0
li \$v0, 1
syscall

li \$v0, 10
syscall
.data

input_request: .asciiz "Input a number to find its fibonacci number: "
result: .asciiz "The result is \n "

ans: The result is printed.

Note:
if the series is; a, a, b, c, d ... then,
"a + a" will give us the next term which is "b", to get the next term (i.e. c) you will have to add the last two terms before it (i.e. a + b). To get "d" its going to be "b + c"...

hi i tried to change it to a: add dl, bl but it won't work

Betty, what compiler are you using?

im using tasm