Pages

                           

Tuesday, January 4, 2011

Multiplication In Hack Assembly Language

This is a HACK Assembly language program to multiply two numbers. The numbers reside in the memory location of Register R0 and R1. This numbers are fetched and manipulated and the result is obtained.
This project is to be done in chapter 4 of the book "Elements Of Computing System". 

The assembly code for Multiplication of two numbers is as shown below:

@i
M=1
(LOOP)
@i
D=M
@R1
D=D-M
@END
D;JGT
@R0
D=M
@mul
M=M+D
@i
M=M+1
@LOOP
0;JMP
(END)
@END
0;JMP

1 comment: