Hi, I'm looking at calling an ASM routine from some C code. I'd like to pass some parameters into the ASM routine, and have it return a value. I don't believe function arguments are passed on the stack, but am not sure of the general mechanism that is used. Any advice? Thanks David
Take a look at the following URL: http://www.keil.com/support/docs/50.htm Jon
A very easy way to do this is to write a skeleton function in "C", the using SRC get the assembly code, cut and paste, insert the assembly guts and voils! you have it. Erik
I agree with you, however, this does not mean you have an authoritative document on the C51 ABI. You can grab a copy of the PowerPC EABI spec. for an example of what an ABI spec. should detail. I'll put the file on my website if anyone cares. Should I write an ABI document for C51? - Mark
This is already well documented in the C51 User's Guide. Jon
"This is already well documented in the C51 User's Guide." One thing missing from the User's Guide (and noted some time back on this forum) is how C51 implements returning a struct from a function. Also, is there a definitive statement of how C51 handles assigning a larger value (eg, char, int) to a bit? We've had some guesses & opinions at http://www.keil.com/forum/docs/thread1315.asp - but what is the defined behaviour?
A struct that is returned from a function:
struct bob_st func (void) { . . . }
void func (struct bob_st) { . . . }
Variables of type bit and bit fields are not the same thing. bit types have a true or false state and can only have the values 0 or 1. When you assign a value to a bit the compiler determines the TRUTH of the value. In other words non-zero values (whether they are bit, char, int, long, or float) have a bit value of 1. Zero values have a bit value of 0. bit fields are a different animal entirely. A bit field has a value from 0 to (2^(number of bits) - 1). When you assign a value to a bit field, the compiler must determine the AMOUNT of the value. If the value is less than the maximum number that can be represented, there is no problem. If the value is larger than the bit field, the compiler must coerce the larger value into the bit field. This is done using the exact same method that is used if you were to assign a long to a character--the additional bits are lost and the original value is masked down to the number of bits represented by the bitfield. On a slightly different note, bit types may have a memory type associated with them, however, this the hardware limits where bits may be located, only the DATA and IDATA memory types may be used with bit variables. Jon
View all questions in Keil forum