Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to assamble the C code in asm code ? #178

Open
joekerrXie opened this issue Apr 10, 2023 · 1 comment
Open

how to assamble the C code in asm code ? #178

joekerrXie opened this issue Apr 10, 2023 · 1 comment

Comments

@joekerrXie
Copy link

i want to build a asm code can call C function . but return some error , how can i assemble the C code in asm code ?

`.text
.global _start
.global foo

_start:
la sp, stack_end
li a0 ,1
li a1 ,2
call foo

stop:
j stop
nop

stack_start:
.rept 10
.word 0
.endr
stack_end:
.end`
ERROR: column 9: "foo" declared global label but not defined.

@Nado15
Copy link

Nado15 commented Aug 21, 2023

Assuming it runs bare metal:

You have to declare your function "foo" in a c file and then compile the assembly file and the c file separately. You need your own linker script as well

Here is a good explanation (you just need to follow the upper part of the answer not all)

https://stackoverflow.com/a/58588918

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants