Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Passing strings to assembler
#1
Hi,

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?
Reply
#2
Uto Wrote:Hi,

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?
I overlook this message! Sorry!! Sad


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 Smile

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)