You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been learning the chapter of 04_Assembly. According to the README.md, after I typed cc -o comp1 -g cg.c expr.c gen.c interp.c main.c scan.c tree.c and./comp1 input01, I got an output 15 and a file out.s:
I have been learning the chapter of
04_Assembly
. According to theREADME.md
, after I typedcc -o comp1 -g cg.c expr.c gen.c interp.c main.c scan.c tree.c
and./comp1 input01
, I got an output15
and a fileout.s
:After that, I got an error. If i typed
cc -o out out.s,
I got :out.s:5:8: error: unknown token in expression pushq %rbp ^ out.s:5:8: error: invalid operand pushq %rbp ^ out.s:6:7: error: unknown token in expression movq %rsp, %rbp ^ out.s:6:7: error: invalid operand movq %rsp, %rbp ^ out.s:7:12: error: unknown token in expression subq $16, %rsp ^ out.s:7:12: error: invalid operand subq $16, %rsp ^ out.s:8:7: error: unknown token in expression movl %edi, -4(%rbp) ^ out.s:8:7: error: invalid operand movl %edi, -4(%rbp) ^ out.s:9:9: error: unexpected token in argument list movl -4(%rbp), %eax ^ out.s:10:7: error: unknown token in expression movl %eax, %esi ^ out.s:10:7: error: invalid operand movl %eax, %esi ^ out.s:11:11: error: unexpected token in argument list leaq .LC0(%rip), %rdi ^ out.s:12:11: error: unknown token in expression movl $0, %eax ^ out.s:12:11: error: invalid operand movl $0, %eax ^ out.s:13:2: error: unrecognized instruction mnemonic, did you mean: casl? call printf@PLT ^ out.s:15:2: error: unrecognized instruction mnemonic leave ^ out.s:19:2: error: unknown directive .type main, @function ^ out.s:21:8: error: unknown token in expression pushq %rbp ^ out.s:21:8: error: invalid operand pushq %rbp ^ out.s:22:7: error: unknown token in expression movq %rsp, %rbp ^ out.s:22:7: error: invalid operand movq %rsp, %rbp ^ out.s:23:11: error: unknown token in expression movq $2, %r8 ^ out.s:23:11: error: invalid operand movq $2, %r8 ^ out.s:24:11: error: unknown token in expression movq $3, %r9 ^ out.s:24:11: error: invalid operand movq $3, %r9 ^ out.s:25:11: error: unknown token in expression movq $5, %r10 ^ out.s:25:11: error: invalid operand movq $5, %r10 ^ out.s:26:8: error: unknown token in expression imulq %r9, %r10 ^ out.s:26:8: error: invalid operand imulq %r9, %r10 ^ out.s:27:7: error: unknown token in expression addq %r8, %r10 ^ out.s:27:7: error: invalid operand addq %r8, %r10 ^ out.s:28:11: error: unknown token in expression movq $8, %r8 ^ out.s:28:11: error: invalid operand movq $8, %r8 ^ out.s:29:11: error: unknown token in expression movq $3, %r9 ^ out.s:29:11: error: invalid operand movq $3, %r9 ^ out.s:30:7: error: unknown token in expression movq %r8,%rax ^ out.s:30:7: error: invalid operand movq %r8,%rax ^ out.s:31:2: error: unrecognized instruction mnemonic cqo ^ out.s:32:8: error: unknown token in expression idivq %r9 ^ out.s:32:8: error: invalid operand idivq %r9 ^ out.s:33:7: error: unknown token in expression movq %rax,%r8 ^ out.s:33:7: error: invalid operand movq %rax,%r8 ^ out.s:34:7: error: unknown token in expression subq %r8, %r10 ^ out.s:34:7: error: invalid operand subq %r8, %r10 ^ out.s:35:7: error: unknown token in expression movq %r10, %rdi ^ out.s:35:7: error: invalid operand movq %r10, %rdi ^ out.s:36:2: error: unrecognized instruction mnemonic, did you mean: casl? call printint ^ out.s:37:11: error: unknown token in expression movl $0, %eax ^ out.s:37:11: error: invalid operand movl $0, %eax ^ out.s:38:7: error: unknown token in expression popq %rbp ^ out.s:38:7: error: invalid operand popq %rbp ^
.I realized that my platform is arm. So, I downloaded x86_64-elf-gcc, and I got:
/opt/homebrew/opt/x86_64-elf-binutils/bin/x86_64-elf-ld: cannot find crt0.o: No such file or directory /opt/homebrew/opt/x86_64-elf-binutils/bin/x86_64-elf-ld: cannot find -lc: No such file or directory collect2: error: ld returned 1 exit status
.Is there any way to help me solve this?
My enviroment:
macOS 14.5 with m1
I guess qemu can be used to run my x86_64 code?
The text was updated successfully, but these errors were encountered: