This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main: | |
addi $t7, $zero, 128 | |
li $v0, 13 | |
la $a0, filename | |
li $a1, 0 | |
li $a2, 0 | |
syscall | |
addi $s0, $v0, 0 | |
readFromFile: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print_msg function takes three arguments and is equivalent to | |
# snprintf(“Move disk %d from %d to %d.”, $a0, $a1, $a2); | |
hanoi: | |
slti $t0, $a0, 2 | |
bne $t0, $0, caseOne | |
addiu $sp, $sp, -20 | |
sw $a0, 0($sp) | |
sw $a1, 4($sp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.include "macros.asm" | |
.data | |
# arrays | |
variables: .space 16 # [random number][low][high][guesses] | |
range: .byte 100 # Set the range [0 t0 range] | |
# Constant strings | |
guess1: .asciiz "Guess a number between " | |
guess2: .asciiz " and " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2002 Manu Datta (gmail.com ID Manu dot Datta) | |
# All rights reserved | |
.data | |
msg1: .asciiz "\nEnter integer values followed by return (-1 terminates input): \n" | |
msg2: .asciiz "," | |
msg3: .asciiz "Bubble Sort" | |
msg4: .asciiz "#########pass#########" | |
msg5: .asciiz "\n" | |
msg6: .asciiz "\nNumber list has been sorted\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.data | |
.text | |
.globl main | |
main: | |
#li $v0, 5 | |
#syscall | |
move $a0, $v0 #sposto l'intero in a0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Joseph Meyer | |
# Colin Zwiebel | |
# 3 Oct 2011 | |
# Palindrome | |
# Recursive implimentation of Palindrome checking algorithm | |
.data | |
input: .asciiz "racecar" | |
input_len: .word 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text | |
main: | |
li $a0, 5 | |
jal fib | |
move $a0, $v0 | |
jal print_int | |
jal print_newline | |
fib: | |
addiu $sp, $sp, -12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.data | |
break: .asciiz "\n" | |
ask: .asciiz "Please enter a random 4 digit number for a seed: " | |
input: .float 4 | |
list : .word 100 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text | |
la $a0, info # Load the start address of the array | |
lw $t0, length # Load the array length | |
sll $t0, $t0, 2 # Multiple the array length by 4 (the size of the elements) | |
add $a1, $a0, $t0 # Calculate the array end address | |
jal mergesort # Call the merge sort function | |
b sortend # We are finished sorting | |
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.data | |
str1: .asciiz "Enter String: " | |
#.align 2 | |
getc: .asciiz "Enter char: " | |
#.align 2 | |
ret: .asciiz "Character <ch> occurs in string <string> <n> times" | |
buffer: .space 100 #space to store our string | |
L1: .space 2 #space for our char | |
L2: .space 4 #space for our char’s frequency in string |
NewerOlder