[英]Printf problem with gcc on mmix
I have compiled the gcc 4.6.0 for mmix according to http://www.bitrange.com/mmix/install.html .我根据http://www.bitrange.com/mmix/install.html为 mmix 编译了 gcc 4.6.0。 After I try their simple hello world, or any other call to printf with more than the first string, only the first string gets printed.在我尝试了他们简单的 hello world 或任何其他对 printf 的调用超过第一个字符串之后,只有第一个字符串被打印出来。 Eg例如
lada@:~/f/c> cat hellommix.c
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char **argv)
{
printf ("hello, %s\n", argc > 1 ? argv[1] : "world");
exit (0);
}
lada@:~/f/c> mmix-gcc hellommix.c
lada@:~/f/c> mmix ./a.out "abc"
hello, lada@:~/f/c>
The generated assembly looks like this:生成的程序集如下所示:
# 1 "hellommix.c"
! mmixal:= 8H LOC Data_Section
.text ! mmixal:= 9H LOC 8B
.section .rodata
.p2align 2
LOC @+(4-@)&3
LC:0 IS @
BYTE "world",#0
.p2align 2
LOC @+(4-@)&3
LC:1 IS @
BYTE "hello, %s",#a,#0
.text ! mmixal:= 9H LOC 8B
.p2align 2
LOC @+(4-@)&3
.global main
main IS @
SUBU $254,$254,24
STOU $253,$254,16
ADDU $253,$254,24
GET $2,rJ
SET $3,$0
SUBU $0,$253,24
STOU $1,$0,0
SUBU $0,$253,12
STTU $3,$0,0
SUBU $0,$253,12
LDT $0,$0,0
SLU $0,$0,32
SR $0,$0,32
CMP $0,$0,1
BNP $0,L:2
SUBU $0,$253,24
LDO $0,$0,0
LDO $0,$0,8
JMP L:3
L:2 IS @
GETA $0,LC:0
L:3 IS @
GETA $5,LC:1
SET $6,$0
PUSHJ $4,printf
PUT rJ,$2
SETL $5,0
PUSHJ $4,exit
.data ! mmixal:= 8H LOC 9B
Try those:试试那些:
fflush (stdout);
放一个fflush (stdout);
before exiting.在退出之前。 (though normally, posix' man 3 exit
tells that all buffers are flushed; maybe something mmix specific) (虽然通常情况下,posix' man 3 exit
告诉所有缓冲区都已刷新;可能是特定于 mmix 的东西)- -
for (int x=0; x!=argc; ++x) {
printf ("arg %d: \"%s\"\n", x, argv[x]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.