hello , I am calling C functions from assembly .The C functions has two float arguments, one variable is in R4 to R7,other is in some memory location assigned by the compiler .How can i pass argument to this memory location ? How can i know this memory location ?Please help ...
Why are you mixing C and assembler like that? Since you are using floating point, it's obvious that you don't require very high execution speed. Why not move the other code to C too?
This is my project.My guide instructed to do in assembly .Only program related to "Fuzzy logic "is written in C since it is complicated ,rest all are in asm (interfacing ADC,LCD, KB).So only complex is done in C(floating point calculation )
.. to write a 'skeleton' file in 'C' and use the generated assembler as a template.
Erik
another method would be to have in asm globals FPin and FPout and then make, in C, an interface module that transferred FPin to the library call and FPout from the library call
I think I would go for global variables with some glue C code.
But another quesion here: Are you expected to be able to generate or decode floating point numbers in your assembler code? That is not a trivial task, which is a big reason why assembler code normally never calls C functions that expects floating point values or returns floating point results.
write a 'skeleton' file in 'C' and use the generated assembler as a template
I'd be extremely wary of the feasibility of that approach. Calling assembler fom C is one thing --- calling C from assembler is a whole more complicated kettle of fish. Just think what desastrous things the linker, particularly the automatic data overlaying mechanism, may do if you call C functions without the linker's full knowledge.
Not even to begin with the quirks you'll run into in a program whose main routine is in asm, thus lacking the C standard library initialization, yet still using C functions.
i got it ...the solution is there in page 169 of C51.pdf...but that is not working ...can anyone tell how to access XDATA memory or make it inside internal RAM of P89V51RD2 since it has 1KB of RAM ....please help ....
the problem got solved ...there is a mistake in C51 ...in the page 171 instead of R0 it should be DPTR ...
from C51 : MOV R0,#?_function?BYTE+3 ; correction: MOV DPTR,#?_function?BYTE+3 ;
somewhere in C51 there is the necessary to make the compiler aware of internal XDATA where rather than in P2, the high address is in some SFR. I suspect that declaring the correct chip will do it. There will be more to it since the internal xdata COULD be external and thus P2/P0 addressed. Anyhow it is documented. OR is it that you have declared pdata and forgot to set the high address SFR in startup.
anyhow it is all somewhere in the documentation.