0
votes

I'm new with assembler and I need some helps.

My compiler reacts to only this commands

load i  
store i 
loadi i 
addi i  
subi i  
move S T    
loadin i j  
storein i j
all kind of jumps

and i need to write program finding factorial of number stores in one of data storage, assume in 1st cell

Thanks in advance

1
I don't recognize that assembly language, but anyway it seems that you need to first learn the basics of the assembly language in question. Also, I think "number stores in one of data storage" makes no sense (should it be "numbers stored in one data storage" ?). And finally, "data storage" and "1st cell" are too vague concepts in the context of assembly languages in general.nrz

1 Answers

0
votes

The first thing you'll need to figure out is how to multiply, because you don't have an opcode to do so. you can do something like:

loop   add mul1 to result
       subtract 1 from mul2
       if counter is greater zero jump to loop

where you are trying to compute mul1 * mul2 and when the loop exits your answer will be in result.

Now you need to figure out how to do the factorial. It would be something like this using the multiply I just wrote:

       load num
       set i = num
top    multipy num and  i
       subtract 1 from i
       if i is greater than 0 jump to top

Now for translating this into your assembler's opcodes, I'm not going to do that. I don't know enough about it, ie how many registers, whats the opcode specification, etc. because there are many different kinds of assembly code.

The main thing that helped me to get started with ASM was breaking down tasks into smaller, more manageable tasks. Good luck!