Last change
on this file since 188 was 2, checked in by Rick van der Zwet, 15 years ago |
Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)
|
-
Property svn:executable
set to
*
|
File size:
739 bytes
|
Rev | Line | |
---|
[2] | 1 | # Dit programma berekent fac(x) voor x=1,...,6, en plaatst de resultaten
|
---|
| 2 | # in mem[200],...,mem[212]. fac(x) = 1.2. ... .x, fac(3)=1.2.3=6.
|
---|
| 3 |
|
---|
| 4 | main:
|
---|
| 5 | addi $7,$0,1 # fac(1) = 1
|
---|
| 6 | addi $5,$0,200 # init base data adress
|
---|
| 7 | sh $7,0($5) # init fac(1) in mem
|
---|
| 8 | nop
|
---|
| 9 | addi $4,$0,2 # init x=2
|
---|
| 10 |
|
---|
| 11 | loop:
|
---|
| 12 | lh $7,0($5) # fac(x-1)
|
---|
| 13 | nop
|
---|
| 14 | add $2,$0,$0 # clear
|
---|
| 15 | add $3,$0,$0 # init mult teller op 0
|
---|
| 16 | IL:
|
---|
| 17 | add $2,$2,$7 # fac(x) := fac(x) + fac(x-1)
|
---|
| 18 | addi $3,$3,1 # mult := mult + 1
|
---|
| 19 | slt $10,$3,$4 # if mult=x then fac(x) is
|
---|
| 20 | bne $0,$10, IL # calculated
|
---|
| 21 | nop
|
---|
| 22 |
|
---|
| 23 | sh $2,2($5) # store fac(x) in mem
|
---|
| 24 |
|
---|
| 25 | addi $4,$4,1 # inc(x)
|
---|
| 26 | addi $5,$5,2
|
---|
| 27 | slti $10,$5,212
|
---|
| 28 | bne $0,$10, loop # if not yet all fac(.) calculated
|
---|
| 29 | nop # then loop
|
---|
| 30 |
|
---|
| 31 | break 0
|
---|
Note:
See
TracBrowser
for help on using the repository browser.