08 March 2013, 16:36 | #1 |
Registered User
Join Date: Feb 2013
Location: Lovisa / Finland
Age: 53
Posts: 80
|
Clean exit of code
Hi,
Clean exit of code, to return t the CLI or Workbench was never important for me when I did my ASM coding some 20-25 years ago. Can someone help me with code for initializing and exiting to gracefully return to the CLI or WB? I need code that compiles on Asm-One v1.20. I can make this myself, but I'd rather not spend time on this, but rather on coding other stuff. I'm going to setup a website for oldskool-coding on Amigas during the weekend, with sources and resources. But these example programs should be able to exit gracefully. Hopefully I can get some help here, otherwise I'll have to make it myself. |
08 March 2013, 16:49 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,026
|
|
18 March 2013, 17:02 | #3 |
Registered User
Join Date: Feb 2013
Location: Lovisa / Finland
Age: 53
Posts: 80
|
So, I made my own, but I read online what other suggested to be done.
Especially the text of xeron on Amiga.org http://www.amiga.org/forums/showpost...19&postcount=3 was of great help. It is made to work on OCS Amigas and can be found in all code examples at http://vikke.net |
21 March 2013, 16:16 | #4 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,655
|
Close any opened libs, then moveq #0,d0;rts if you haven't turned off interrupts etc
Else you just restore what hardware registers you changed and do the same. (To restore the copper list pointer(s) you must get the current pointers from graphics.library at the start). It's considered good form to restore all registers (except d0) before exit. If you want to be compatible with Amigas with graphics cards, you should wait for vertical blank twice and restore the Intuition view the program was started from. |
21 March 2013, 17:01 | #5 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Why do we clear d0?
|
21 March 2013, 17:54 | #6 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,026
|
D0 contains the return code. If you return 10 or higher, you get a "command xy failed return code nn" message. If you return -1 you get "xy: unknown command".
|
22 March 2013, 11:55 | #7 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,539
|
|
23 March 2013, 01:25 | #8 | |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,655
|
Quote:
Some startups wait for end of frame, then set copperptr and trigger the new copper, even though it's not necessary. This is verbatim, logical, independent code that works - but you could argue the same there, "everyone knows it's not necessary". I think spelling it out is sometimes pedagogical and sensible. |
|
23 March 2013, 08:07 | #9 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,570
|
Commands don't need to save/restore registers, except of course stack pointer
Quote:
|
|
23 March 2013, 22:38 | #10 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,655
|
I know the exceptions, and I bet you see some weird and sometimes incorrectly programmed startups that you have to handle But as I see it the topic is about a normal startup and what should be in it.
If I were to nitpick I could f.ex. say that you don't have to save/restore the stack pointer, because if it were trashed you wouldn't RTS to the code that restores it. Startup code is a relative thing. There is no way to write a perfectly safe wrapper, if you were to do proprietary things with the hardware as if it were your own, if it's executed while a task using a shared hardware resource is running, for example running a custom hardware-musicplayer while running a modplayer with the OS. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
AmigaXL install error (tar exit code) | kayt | support.Apps | 3 | 28 July 2010 23:00 |
Cannot exit from Some games | @UAE | project.WHDLoad | 13 | 19 November 2008 13:28 |
WinUAE crashes on exit | glwxxx | support.WinUAE | 13 | 19 August 2006 11:41 |
OS 3.9 can't exit and some more problems | Tea | support.WinUAE | 1 | 09 July 2003 12:51 |
WHERE is the goddammit exit (Leander)? | T.R.Schmidt | support.Games | 2 | 08 April 2003 15:42 |
|
|