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

# Next directive defines additions to the data segment

.data
.align 2		; Start on 4 byte boundary
msg:
	.asciz	"Welcome to PowerPC assembly programming!\n"
	
# Next directive defines additions to the text (code) segment

.text
.align 2		; Start on a 4 byte boundary
.globl	_main	; Make the _main symbol visible outside this module
_main:
	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		r3,hi16(msg)	; Put high 16 bits of msg address into r3
	ori		r3,r3,lo16(msg)	; or in the low 16 bits
	
	bl		_print_string	; Print out the string
	
	addi	r1, r1, 32
	lwz		r0, 8(r1)
	mtlr	r0
	blr

