Nand2Tetris Questions and Answers Forum
›
Architecture
›
Project 4
Search
everywhere
only in this topic
Advanced Search
mult.asm
Classic
List
Threaded
♦
♦
Locked
3 messages
sharmaankush347
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
mult.asm
mult is showing 0x0=-1 with script otherwise no such issue without script. Here's screenshot...kindly tell me mistake if any
Thanks
multquery.jpg
WBahn
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Re: mult.asm
Administrator
I can't evaluate your code if I can't see all of your code.
Have you walked through the code execution by hand to see what it does?
sharmaankush347
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Re: mult.asm
ya,even its working without script, I modified the repeat 20 to some higher value in script. Here's my code-
@R2 //making R2 =0
M=0
@R0
D=M
@ZERO
D;JEQ //if R0=0, goto ZERO
@R1
D=M
@ZERO
D;JEQ //if R1=1, goto ZERO
@i
M=1 //i=1
@Prod // Product
M=0 // Product=0
(LOOP)
@i
D=M
@R0
D=D-M //D=i-RAM[0]
@STOP
D;JGT //IF i-n>0, GOTO STOP
@Prod
D=M
@R2
M=D
@R1
D=D+M // D=Prod+m
@Prod
M=D //Prod=Prod+m
@i
M=M+1 //i=i+1
@LOOP
0;JMP //UNCONDITIONAL JUMP
(ZERO)
@R2
M=0
//@R2
D=M
@END
0;JMP
(STOP)
@Prod
D=M
@R2
M=D // RAM[2]=Prod
@END
0;JMP
(END)
@END
0;JMP
Free forum by Nabble
Edit this page