斐波那契程序_斐波那契系列程序| 8085微处理器

斐波那契程序

Problem statement:

问题陈述:

Write an assembly language program in 8085 microprocessor to generate Fibonacci series.

在8085微处理器中编写汇编语言程序以生成Fibonacci系列。

Example: Assume Fibonacci series is stored at starting memory location 3050.

示例:假设斐波那契数列存储在起始存储位置3050中。

    3050 = 00, 3051 = 01, 3052 = 02, 3053 = 03 and so on.

Note: This program generates Fibonacci series in hexadecimal numbers.

注意:此程序以十六进制数生成斐波那契数列。

Algorithm:

算法:

  1. Initialize register H with 30 and register L with 50, so that indirect memory M points to memory location 3050.

    用30初始化寄存器H并用50初始化寄存器L,以便间接存储器M指向存储器位置3050。

  2. Initialize register B with 00, register C with 08 and register D with 01.

    用00初始化寄存器B,用08初始化寄存器C,用01初始化寄存器D.

  3. Move the content of B in M.

    将B的内容移至M。

  4. Increment M by 1 so that M points to next memory location.

    将M递增1,以使M指向下一个存储位置。

  5. Move the content of D in M.

    在M中移动D的内容。

  6. Move the content of B in accumulator A.

    将B的内容移动到累加器A中。

  7. Add the content of D in A.

    在A中添加D的内容。

  8. Move the content of D in B.

    在B中移动D的内容。

  9. Move the content of A in D.

    在D中移动A的内容。

  10. Increment M by 1 so that M points to next memory location.

    将M递增1,以使M指向下一个存储位置。

  11. Move the content of A in M.

    将A的内容移到M中。

  12. Decrements C by 1.

    将C减1。

  13. Jump to memory location 200D if ZF = 0 otherwise Halt the program.

    如果ZF = 0,则跳转到内存位置200D,否则暂停程序。

Program:

程序:

ADDRESSMNEMONICSCOMMENTS
2000LXI H, 3050H ← 30, L ← 50
2003MVI C, 08C ← 08
2005MVI B, 00B ← 00
2007MVI D, 01D ← 01
2009MOV M, BM ← B
200AINX HM ← M + 01
200BMOV M, DM ← D
200CMOV A, BA ← B
200DADD DA ← A + D
200EMOV B, DB ← D
200FMOV D, AD ← A
2010INX HM ← M + 01
2011MOV M, AM ← A
2012DCR CC ← C – 01
2013JNZ 200DJump if ZF = 0
2016HLTEND
地址 记忆 注释
2000 LXI H,3050 高←30,长←50
2003年 MVI C,08 C←08
2005年 MVI B,00 B←00
2007年 MVI D,01 D←01
2009年 MOV M,B M←B
200A INX H M←M + 01
200B MOV M,D M←D
200度 MOV A,B A←B
200D 添加D A←A + D
200E MOV B,D B←D
200楼 MOV D,A D←A
2010 INX H M←M + 01
2011年 MOV M,A M←A
2012年 DCR C C←C – 01
2013年 JNZ 200D 如果ZF = 0则跳转
2016年 HLT 结束

Explanation: Registers A, B, C, D, H, L are used for general purpose.

说明:寄存器A,B,C,D,H,L用于通用。

  1. LXI H 3050: assigns 30 to H and 50 to L.

    LXI H 3050:将30分配给H,将50分配给L。

  2. MVI B, 00: assigns 00 to B.

    MVI B,00:将00分配给B。

  3. MVI C, 08: assigns 08 to C.

    MVI C,08:将08分配给C。

  4. MVI D, 01: assigns 01 to D.

    MVI D,01:将01分配给D。

  5. MOV M, B: moves the content of B in M.

    MOV M,B:移动M中B的内容。

  6. INX H: increment M by 1.

    INX H:将 M递增1。

  7. MOV M, D: moves the content of D in M.

    MOV M,D:在M中移动D的内容。

  8. MOV A, B: moves the content of B in A.

    MOV A,B:移动B在A中的内容。

  9. ADD D: add the content of D and A. Store the result in A.

    添加D:添加D和A的内容。将结果存储在A中。

  10. MOV B, D: moves the content of D in B.

    MOV B,D:移动B中D的内容。

  11. MOV D, A: moves the content of A in D.

    MOV D,A:在D中移动A的内容。

  12. INX H: increment M by 1.

    INX H:将 M递增1。

  13. MOV M, A: moves the content of A in M.

    MOV M,A:在M中移动A的内容。

  14. DCR C: decrements C by 1.

    DCR C:将C减1。

  15. JNZ 200C: jump to memory location 200D if ZF = 0.

    JNZ 200C:如果ZF = 0则跳转到存储位置200D。

  16. HLT: stops executing the program and halts any further execution.

    HLT:停止执行程序,并停止任何进一步的执行。

翻译自: https://www.includehelp.com/embedded-system/fibonacci-series-program-using-8085-microprocessor.aspx

斐波那契程序

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值