All pastes #967007 Raw Edit

Something

public text v1 · immutable
·published 2008-04-02 03:42 UTC
rendered paste body
.text



.globl swap
swap:
		addi $sp, $sp, -8 	# Make space on stack
		sw $ra, 0($sp) 		# Save return adress

		sll $t1, $a1, 2
		add $t1, $a0, $t1

		lw $t0, 0($t1)
		lw $t2, 4($t1)

		sw $t2, 0($t1)
		sw $t0, 4($t1)

		lw $ra, 0($sp)	# Restore return adress
		addi $sp, $sp, 8	# Restore stack pointer
		jr $ra			# Return



.globl	main

main:
li $a0, 2
li $a1, 3
 
	addi $sp, $sp, -4	# Make space on stack
	sw $ra, 0($sp)		# Save return adress

	# Print the integer result in a0
	li $v0, 1	# Load the system call number
	syscall

	# Print endl
	la $a0, endl	# Load the adress of the string
	li $v0, 4	# Load the system call number
	syscall
	
	# Return.
	li $v0, 0	# Load return value in v0
	
	lw $ra, 0 ($sp)		# Restore return adress
	addi $sp, $sp, 4	# Restore stack pointer

	jr $ra		# Return.

.data

endl: .asciiz "\n"

# End of program