#-------------------------------------------------------------------------------
# Thomas C. Bressoud
# 29 December 2005
# addAB.s
#
# Description:  Simple first program that does nothing
#-------------------------------------------------------------------------------

# Next directive defines additions to the data segment

.data
.align 4		; Start on 16 byte boundary

.globl A
A:	.long	25	; Allocate a 4 byte data word
.globl B
B:	.long	17  ; Allocate another 4 byte data word

# Next directive defines additions to the text (code) segment

.text
.align 4		; Start on a 16 byte boundary
.globl	_main	; Make the _main symbol visible outside this module
_main:
.line 25
	mflr	r0			; Put the return address from main into r0
	stw		r0,8(r1)	; Save in the linkage of the callers stack frame
	stwu	r1,-32(r1)	; Allocate a new stack frame, updating the stack ptr
	lis		r9, ha16(A)	; Load high 16 bits of address of A
	lwz		r4, lo16(A)(r9) ; and low 16 bits of address
	lwz		r5, lo16(B)(r9)
	
	add		r3,r4,r5

	bl		_print_int
	
	addi	r1, r1, 32
	lwz		r0, 8(r1)
	mtlr	r0
	blr

