ここに私の問題があります。scanf() を使用してユーザー入力から文字を取得し、それを SPARC Assembly でユーザーに出力しようとしています。このコードは、私が実際にやろうとしていることよりも単純ですが、それは私が夢中になっていることです. 文字列では問題なく機能しますが、何らかの理由で文字では機能しません。
SPARC コード:
.section ".data"
prompt: .asciz "\nPlease enter your name: "
format: .asciz "%c"
format2: .asciz "Your name is:%c\n"
/* Program starts */
.align 4
.section ".text"
.global fun
fun:
save %sp, -96, %sp ! save the stack
set prompt, %o0 ! point o0 to the prompt
call printf ! call printf to print the prompt
nop
set format, %o0 ! point o0 to the input format string
set ch, %o1 ! point o1 at the input variable
call scanf ! get the input into this variable
nop
set format2, %o0 ! point o0 to the output format
set ch, %o1 ! point o1 to the string to be displayed
call printf ! print the string pointed by o1
nop
ret ! return
restore ! get out
C コード:
#include <stdio.h>
char ch;
int main()
{
fun();
}