Reputation: 97
i declared a table(array) in .h file.
Now i want to use that file in .asm but i am unable to include .h into .asm
Help me out
Upvotes: 0
Views: 83
Reputation: 225232
Assuming a C declaration something like:
char array[] = { 1, 2, 3, 4, 5 };
You can use it in your assembly file like this:
.globl _array
lea _array(%rip), %rbx
movb (%rbx), %al
The lea
instruction puts the base address of array
into rbx
, and then the movb
instruction grabs the first byte out. You could use 1(%rbx)
to get array[1]
, and so forth.
NB - my example is from a Mac OS X test app I just made. If you're on a different system, you might have to do something different.
Upvotes: 0