【发布时间】:2015-09-30 23:46:35
【问题描述】:
当我们知道前 2 个元素时,我从大学得到了一项任务来计算 10 个元素的斐波那契数列。 在过去的几个小时里,我一直在尝试这样做,但我在途中迷路了。
这是我的代码:
IDEAL
MODEL small
STACK 100h
DATASEG
Fiburnachi db 0, 1, ?, ?, ?, ?, ?, ?, ?, ?
TenTimes db 8
CODESEG
start:
mov ax, @data
mov ds, ax
xor ax, ax
xor bx, bx
xor cx, cx
mov cl, [TenTimes]
lea bx, [Fiburnachi]
FibLoop:
mov al, [bx] //This is my first attempt.
add al, [bx+1] //i have tried using only the "ax" register,
inc [bx] //i can't seem the find the correct way to
mov [bx], al //store the value I have in al (last result)
mov al, [bx] //This Doesn't work I dunno why really.
mov dl, [bx+1]
add al, dl
mov [bx+1], al
inc [bx]
FibLoop
我认为我对通过数组索引正确循环和分配的理解是错误的。
这样做的正确方法是什么?我是否必须为计算本身使用 2 个寄存器?
【问题讨论】:
标签: loops assembly x86-16 tasm