!-------------------------------------- ! hellosp.S ! Fundamentals ! Calling Functions !-------------------------------------- #define MAX_NAME_LENGTH 100 !-------------------------------------- .section ".rodata" pcPrompt: .asciz "What is your name? " pcScanfFormat: .asciz "%s" pcGreeting: .asciz "Hello %s.\n" !-------------------------------------- .section ".data" !-------------------------------------- .section ".bss" pcName: .skip MAX_NAME_LENGTH !-------------------------------------- .section ".text" .align 4 .global main main: save %sp, -96, %sp ! printf("What is your name? "); set pcPrompt, %o0 call printf nop ! scanf("%s", pcName); set pcScanfFormat, %o0 set pcName, %o1 call scanf nop ! printf("Hello %s.\n", pcName); set pcGreeting, %o0 set pcName, %o1 call printf nop ! return 0; mov 0, %i0 ret restore