Calling a euphoria func from asm
- Posted by Alexander Toresson <toressonodakra at swipnet.se> Jul 06, 2004
- 499 views
I've been trying to call a function written in euphoria from some asm code, though I've had little success. I'm first trying to call a func with no arguments, and I'll expand it later. Here's the code:
include machine.e include dll.e include asm.e atom caller, hiproc function HelloWorld(integer a) puts(1, "Hello World!\n") return 0 end function hiproc = call_back(routine_id("HelloWorld")) caller = get_asm("pushad\n" & "call near #" & sprintf("%x", hiproc) & "\n" & "popad\n" & "ret") call(caller) if wait_key() then end if
As far as I know, nothing should be pushed when calling a function which doesn't have any arguments. I've looked up the calling convention and I've not found any info about something that should be pushed in this case. An interesting thing is that if you change "call(caller)" to "call(hiproc)" you'll get the "Hello World" printed, though the program crashes after that. Maybe because of that call() doesn't save any registers? Regards, Alexander Toresson Shhh! Be vewy quiet! I'm hunting wuntime ewwows!