hi Pelles
can you post an example that show us hwo can we use DB,DW,DD in
asm block.
and hwo can we access it form c part.
thanks
Emil
Hello Emil,
Maybe not exactly what you are looking for, but this is one way of doing it. DB, DW, DD all emit data to the code section, so you should either put it after a ret (probably best), or use jmp xxx, to jump around the data.
__declspec(naked) unsigned long * test(int idx)
{
__asm {
mov eax,[esp+4] ; idx (0-7)
add eax,eax ; *2
add eax,eax ; *4
add eax,offset label
ret
align 4
label: dd 1,2,3,4,5,6,7,8
}
}
It's easiest to access the data from the assembly code. If you want to access data from C, I don't see that much benefits with DB, DW, DD. Might as well do something like this:
static unsigned int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
( If you really need the data in the code section, you can use #pragma data_seg() )
Pelle
thanks Pelles.
this will help a lot.
Emil