All pastes #968143 Raw Edit

Someone

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



.globl swap
swap:


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

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

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

		jr $ra			# Return



.globl	main

main:

	addi $sp, $sp, -4	# Make space on stack
	sw $ra, 0($sp)		# Save return adress


li $a0, 2
li $a1, 3




jal swap
 


	# 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