Image Map Image Map
Results 1 to 5 of 5

Thread: Basic <-> Assembly RTSm USR, SYS not working ? Suggested text??

  1. #1

    Default Basic <-> Assembly RTSm USR, SYS not working ? Suggested text??

    This is a continuation of my previous thread on connecting Basic to Assembly. Thanks to all who responded.

    I got one small simple program (Basic -> Assembly -> Basic) to run nicely. I have used RTS, USR, SYS, $C000,$8000 etc. I thought I had "gotten it"!!

    However, all subsequent small modifications to the small Assembly program have not worked. They do not return to Basic with RTS. Instead they either crash or lock up the system!

    I have the texts "C64 Prog Ref Guide" and "C64/128 Assembly Language Programming" (Mark Andrews) but these do not detail this issue well (or I am not finding it !!). I use the C64 Macro Assembler Development System.

    Can anyone suggest a text with examples (Basic <-> Assembly???/ I can track anything down on the web or eBay!

    Thanks.

  2. #2
    Join Date
    Jan 2014
    Location
    Centero
    Posts
    6,781
    Blog Entries
    2

    Default

    You've got a stack problem. If RTS doesn't return you to where it should, either something is missing from the stack, or something's there which shouldn't be.

    You can prove this by poking an RTS into a memory location (RTS is $60 or 96 decimal) and SYS there; you'll be back in basic right after your SYS.

    POKE 49152,96:SYS 49152 appears to do nothing but really it does what I described.

    So either you have errant code which is manipulating the stack wrongly, or your assembler is doing something funky. Do you have any PLA or PHA in your code? Are you JMP or JSR or branching somewhere that's causing a crash before your RTS?
    Last edited by KC9UDX; April 16th, 2019 at 11:17 PM.

  3. #3
    Join Date
    Jan 2014
    Location
    Centero
    Posts
    6,781
    Blog Entries
    2

    Default

    BTW, I don't use USR, so I don't know if it does but some BASICs have commands like this which push values into the stack for your assembly code to retrieve. For certain, SYS does not do this; so until someone verifies that USR doesn't, use SYS until you get everything working.

    Post your code here and it should be easy for us to work it out.

  4. #4

    Default Looking at this..I'll post code shortly

    Quote Originally Posted by KC9UDX View Post
    BTW, I don't use USR, so I don't know if it does but some BASICs have commands like this which push values into the stack for your assembly code to retrieve. For certain, SYS does not do this; so until someone verifies that USR doesn't, use SYS until you get everything working.

    Post your code here and it should be easy for us to work it out.
    ************************************************** **************************

    Thank you for the insight. I will try this over the weekend, and post the simple code. It does nothing fancy, and I'll simplify it even more. The simple Assembly code just wrote the alphabet to the screen. It was called by Basic and returned to Basic with both the USR and SYS "calls".

    The follow on codes just tried to write "Hello Tony" and wouldn't RTS to Basic.

    ************************************************** ****************

    Thanks again.

  5. #5
    Join Date
    Jan 2014
    Location
    Centero
    Posts
    6,781
    Blog Entries
    2

    Default

    You're quite welcome.

    I'm not an expert, but I've completed many massive projects on the C64 over the years, and lately I've been heavily immersed in one. In a couple of days recently, I've pounded out around 2000 lines of assembly code. So solving a simple problem will be fun.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •