!-------------------------------------- ! fromascii.S ! Load and Store Instructions !-------------------------------------- .section ".rodata" pcPrompt: .asciz "Enter an ASCII code: " pcScanfFormat: .asciz "%d" pcResult: .asciz "The character with that ASCII code is %c.\n" !-------------------------------------- .section ".data" !-------------------------------------- .section ".bss" pcChar: .skip 1 .align 4 piAsciiCode: .skip 4 !-------------------------------------- .section ".text" .align 4 .global main main: save %sp, -96, %sp ! printf("Enter an ASCII code: ") ; set pcPrompt, %o0 call printf nop ! scanf("%d", &iAsciiCode); set pcScanfFormat, %o0 set piAsciiCode, %o1 call scanf nop ! cChar = (char)iAsciiCode; set piAsciiCode, %l0 ld [%l0], %l1 set pcChar, %l2 stb %l1, [%l2] ! printf("The character with that ASCII code is %d.\n", cChar); set pcResult, %o0 set pcChar, %o1 ldub [%o1], %o1 call printf nop ! return 0; mov 0, %i0 ret restore