• Re: Power C/asm: returning a value from asse

    From K-Guide@1:130/230 to All on Saturday, December 14, 2019 04:39:15
    On Sat 14-Dec-2019 5:17a, Harry Potter@3:770/3.0 said to Harry Potter:
    I found it. :) Sorry for wasting your time. :(

    It is never a waste of time to ask a question, especially in a public forum as others do learn from the dialog. You never know when a simple questions that has been asked before may spark insights or the imagination of the other readers.

    In your case, I am now courious how Power C does handle passing arguments and the return value from a function in assembler?

    [+] K-Guide
    --- CNet/5
    * Origin: Future World II - fw2.cnetbbs.net:6800 (1:130/230)
  • From Harry Potter@3:770/3 to K-Guide on Saturday, December 14, 2019 08:48:02
    On Saturday, December 14, 2019 at 11:41:28 AM UTC-5, K-Guide wrote:
    On Sat 14-Dec-2019 5:17a, Harry Potter@3:770/3.0 said to Harry Potter:
    I found it. :) Sorry for wasting your time. :(

    It is never a waste of time to ask a question, especially in a public forum
    as
    others do learn from the dialog. You never know when a simple questions that has been asked before may spark insights or the imagination of the other readers.

    In your case, I am now courious how Power C does handle passing arguments and the return value from a function in assembler?

    [+] K-Guide

    It seems that I have to pass the return value in the TOS, but what if the function has no parameters or too few parameters?

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From K-Guide@1:130/230 to All on Saturday, December 14, 2019 17:10:07
    On Sat 14-Dec-2019 8:48a, Harry Potter@3:770/3.0 said to K-Guide:
    It seems that I have to pass the return value in the TOS, but what if the function has no parameters or too few parameters?

    Using the stack makes alot of since for the return value of the assembler function. In the case of no parameter, I suspect you can just call the routine
    via a function pointer in C. Set that to the address of your assembler routine
    and call the function. Please bear in mind I am not a Power C programmer, but
    am just guessing based on other platforms I program on. If you have parameters there could be some documemtation on how to pass them via registers in the compiler docs. Compilers seem to have their own style for stuff like that. It also could be that you just need to drop the values into a certain memory location as the assember routine expects it there.

    Not sure I follow you about the too few parameters.

    [+] K-Guide
    --- CNet/5
    * Origin: Future World II - fw2.cnetbbs.net:6800 (1:130/230)
  • From Harry Potter@3:770/3 to K-Guide on Saturday, December 14, 2019 17:03:23
    On Saturday, December 14, 2019 at 7:17:21 PM UTC-5, K-Guide wrote:
    Using the stack makes alot of since for the return value of the assembler function. In the case of no parameter, I suspect you can just call the
    routine
    via a function pointer in C. Set that to the address of your assembler
    routine
    and call the function. Please bear in mind I am not a Power C programmer,
    but
    am just guessing based on other platforms I program on. If you have
    parameters
    there could be some documemtation on how to pass them via registers in the compiler docs. Compilers seem to have their own style for stuff like that.
    It
    also could be that you just need to drop the values into a certain memory location as the assember routine expects it there.

    Not sure I follow you about the too few parameters.

    The docs. I have reveal that the return value seems to overwrite the last parameter passed to the function. That's why I am worried about the too few parameters.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From K-Guide@1:130/230 to All on Sunday, December 15, 2019 09:01:21
    On Sat 14-Dec-2019 5:03p, Harry Potter@3:770/3.0 said to K-Guide:
    The docs. I have reveal that the return value seems to overwrite the last parameter passed to the function. That's why I am worried about the too few parameters.

    Ahhh. That does seem odd as I would have though the assember routine would pull from the stack each of its parameters. Sounds like some small prototype code is needed to test this out and determine how this works.

    Are you writing the assembler fuctions or just the C portion of the code?

    [+] K-Guide
    --- CNet/5
    * Origin: Future World II - fw2.cnetbbs.net:6800 (1:130/230)
  • From Harry Potter@3:770/3 to All on Sunday, December 15, 2019 16:21:23
    Admittedly, I'm not currently using Power C but am working on special support for it. I also want to create some libraries for it, and some of those functions are better off in Assembler.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From K-Guide@1:130/230 to All on Sunday, December 15, 2019 21:45:21
    That cool your working to expand Power C. I have considered doing some C level
    programming on the C64 via cc65, but never got around to it.

    [+] K-Guide
    --- CNet/5
    * Origin: Future World II - fw2.cnetbbs.net:6800 (1:130/230)
  • From Harry Potter@3:770/3 to All on Saturday, December 28, 2019 08:20:30
    Try https://www.lyonlabs.org/commodore/onrequest/powerc/index.html. :)

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)