11-09-2016, 04:33 PM
Uto Wrote:Hi,I overlook this message! Sorry!!
I have this code:
Code:.....
PRINT "Please enter text:"
LET a$= INPUT(8)
SAVEFILE(a$)
.....
SUB fastcall SAVEFILE(name as String)
ASM
.....
END ASM
END SUB
I need to get the string value in the ASM function, and I was expecting having a pointer to it as the second value in stack (so POP HL, POP DE, PUSH HL will keep the return adress in stack and DE as pointer to the string), but it doesn't seem to work like that, How could I get the string parameter from assembler?
If your function only have one parameter like in your case, and you use FASTCALL, the pointer comes *already* in HL. You have to do nothing
For FASTCALL the convention is:
- 8 bits (Byte, UByte) -> A register
- 16 bits (Integer, UInteger, STRING) -> HL
- 32 Bits (LONG, FIXED) -> HL, DE (HL = Low part, DE = High Part)
- 40 Bits (Float) -> HL,DE -> Mantissa. A -> Exponent
For strings, better use ByVar to really get the pointer to the pointer. If not, remember to call FREE upon return or you will end UP with a memory leak.