Is it possible to access variables defined in assembly from C? -


can read or write variable defined in assembly file in c file? couldn't figure out on own. example c file looks follows:

int num = 33;

and produces assembly code:

.file   "test.c" .globl  _num .data .align 4 

_num: .long 33

as started learn assembly heard speed reason why have pick assembly adn lower file size , stuff...

i using mingw(32 bit) gnu assembly on windows7

yes, linker combines .s files , makes single object file. c files first become assembly files. each assembly file have import list, , export list. export list contains variables have .global directive. import list contains variables start extern in c file. if assembly file contains this:

.file   "test.c" .globl  _num .data .align 4 

all need in order use num, create extern variable this

extern int num 

and you'll able read or modify it.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -