nand2tetris【6】

博主基于之前学习的ARM9芯片汇编语言知识,继续nand2tetris的学习。他编写了实现乘法功能的代码,通过循环完成任务。在编写Mult.asm的过程中遇到问题,代码效果与书中的描述不符,输出点逐个显示。经过搜索,发现需要将M设置为-1而非1。然而,清除屏幕的代码存在缺陷,未从屏幕开头开始清除。尽管知道不应拖延,但博主决定暂时搁置,专注于CPU的构建。
摘要由CSDN通过智能技术生成

I'm glad that i had learned some assembly language  knowledge where i study ARM9 chip.


So i do not need to stop my pace to study assembly language.微笑


First,we need to write a code to achieve mutiplication function.


Just make good use of loop can help you finish it.

Mult.asm

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/04/Mult.asm

// Multiplies R0 and R1 and stores the result in R2.
// (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[3], respectively.)

// Put your code here.
@0
D=M
@2
M=0
(LOOP)
@1
D=M
@END
D;JEQ

@1
M=M-1

@0
D=M
@2
M=M+D

@1
D=M
@LOO
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值