
I've also been working through some Console Development work, paying special attention to branching and looping in MIPS. Below is a program i made that adds 1 + 2 + 3 + .... 100.
##Program that computes the sum 1 + 2 + 3 + ... 99 + 100
##
.text
.globl main
main:
ori $8,$0,1 ## sum
ori $9,$0,2 ## counter
ori $10,$0,101 ## number of iterations
loop:
beq $9,$10,exit ## goes to exit if counter is the same as number of iterations
sll $0,$0,0 ## sponge for excess machine cycles
add $8,$8,$9 ## adding the counter to the sum
addi $9,$9,1 ## add 1 to the counter
j loop ## back to loop
sll $0,$0,0 ## sponge for excess machine cycles
exit:
sll $0,$0,0
you can see here that the final answer is put in register 8

(13BA In decimal format is equal to 5050).
In Games Development Techniques we have been assigned to make a mini game for our map, which could come in useful for our final project. I'll be looking into the pickup class and interaction class in particular this week to make my mini-game. Ill post once i have completed it =D.
0 comments:
Post a Comment