Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
19 June, 2013, 13:52:36 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: 1 ... 8 9 [10] 11 12 ... 42   Go Down
  Print  
Author Topic: Routines -  (Read 43049 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
SirCmpwn
Guest
« Reply #135 on: 21 March, 2010, 18:37:37 »
0

Let me see if i understand the concept behind the global data concept.  When the program is run, it is copied to RAM somewhere safe where the TiOS can run it.  After it is finished executing, it is NOT copied back, making the program effectively write protected Undecided. So all we need to do is write a little bit of code to find out where the program acualy located (the first hex code) and store it in a safe place (L4) until the end of the program where we use it.  Once we get to the end, we merely copy the program right back to where it started again, so that any changes we made are permanent.  We are not using any of the L1-L6 variables for anything more than a 4 byte address storage during the program execution, so there is no possibility that we could run out of memory due to large programs.

(did i get that correctly?)

Yeah, calc84 is right.  When you first run a program, TIOS stores the name of it to OP1 (a RAM area).  I read OP1 and store it to the end of L4.  That is what the first routine does.  Only 9 bytes.
« Last Edit: 21 March, 2010, 18:39:19 by SirCmpwn » Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 10:47:05
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50634


Total Post Ratings: +2637

View Profile WWW
« Reply #136 on: 21 March, 2010, 19:24:37 »
0

For some reasons, I am even more confused after reading Builderboy post. I think I'll just give up on the whole Self-modifying code concept and wait until Quigibo implements an axe feature that allows us to do so in an easier to understand manner (if it's even possible for those used to using SMC the CelticIII/Y= way), or wait until external variable storage/reading (appvar maybe?) is supported
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
SirCmpwn
Guest
« Reply #137 on: 21 March, 2010, 19:42:59 »
+1

If you don't want to read a huge post, the juicy stuff is in the last two paragraphs, down at the bottom.

Here, let me do my best to explain it.
The memory is a series of bytes.  A very long series of bytes.  Each byte is represented by an offset from the first byte, called an address.  Addresses are almost always written in hex.  For example, 0A00h is 10 bytes from the first byte.  0000h is the first byte.  Notice that numbers in hex are ended with an 'h'.  Now, Axe creates program LOL and outputs it to a spot in memory.  For the purposes of this example, we will say it's at B2C4h.  When you run a program, there is another address in memory called OP1 that TIOS copies the name of the program to.  So, when you run prgmLOL, OP1 looks like this:
ProtProgObj (this represents a protected program), L, O, L, 0, 0, 0, 0, 0
You may have noticed that you can only have up 8 character names in TIOS.  In reality, all names have 9 characters - the identifier (ProtProgObj in this case), and the name, buffered by zeros.  So, if a name is less than 8 characters (like LOL), zeros are added to make it equal 8.
Now, when you run the first routine, it looks at OP1, and copies it to 8384h (tempSwapArea, or L4, plus 223).  This means that it copies the name of the program to the end of L4.
Additionally, programs are not run from where they are saved.  If a program is saved to B2C4h, TIOS copies it to 9D95h to run it.  When the program ends, however, it is not copied back to B2C4h, essentially making it write protected.  This is important, because any changes we make will not be copied.
When you run the second routine, it copies the end of L4 back to OP1.  This is because, during the course of the program, it is possible for OP1 to change, so we back up the name first.  There is a routine provided by TIOS for looking up variables by name.  It requires the name to be in OP1, and when we call it, it will return B2C4h (remember, that's where the program is saved?).  We already know the program is running at 9D95h.  This is the most up-to-date version, the one with the modified data.  We need to keep that modified data, and the only way to do that is to copy it back to B2C4h.  So, when TIOS tells us the program is at B2C4h, we copy all the data from 9D95h to B2C4h.  This saves the modified data for the next time.

If you have any questions about this, please feel free to ask.  I want to make sure that you are comfortable with this, because it is the only way right now to save external data.

Also, if you are concerned about speed and the time it would take to copy it, think of it this way.  TIOS copies the program to 9D95h before running it.  We copy it from 9D95h when you call the second routine.  So, if you want to get a general idea of how long it might take, watch how long it takes to start, because that is exactly how long it will take to run the second routine.
Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 10:47:05
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50634


Total Post Ratings: +2637

View Profile WWW
« Reply #138 on: 21 March, 2010, 20:03:54 »
0

OK so basically it's not the entire program content that is copied to OP1, just the name, right? No data from the program where your routine is ran is copied to OP1?

Also btw just so it is clear, since I thought people got the idea before: I am not concerned about the speed it takes to copy anything especially if it's just gonna be used for saving/loading.
« Last Edit: 21 March, 2010, 20:05:05 by DJ Omnimaga » Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
SirCmpwn
Guest
« Reply #139 on: 21 March, 2010, 20:20:28 »
0

OK so basically it's not the entire program content that is copied to OP1, just the name, right? No data from the program where your routine is ran is copied to OP1?

Right.  Just 9 bytes.  Never enough to do damage.
Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 10:47:05
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50634


Total Post Ratings: +2637

View Profile WWW
« Reply #140 on: 21 March, 2010, 20:32:57 »
0

That's good then. I misunderstood yesterday, I was convinced the entire program data stored at its end had to be copied during writeback.
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
SirCmpwn
Guest
« Reply #141 on: 21 March, 2010, 21:38:36 »
+4

I made another routine, here is is:
Axe Programs in MirageOS
The attached program will help you get your Axe programs to show up in MirageOS.  Draw a 15x15 icon in the top-left hand corner of the graph screen and run the attached program.  Copy the resulting code into the first line of your program.  If you are also using my writeback routine, make sure this code comes before the first writeback routine.

* AxeMirageOS.8XP (0.69 KB - downloaded 83 times.)

* MirageOSWithAxe.gif (282.73 KB, 192x128 - viewed 312 times.)
Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 10:47:05
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50634


Total Post Ratings: +2637

View Profile WWW
« Reply #142 on: 21 March, 2010, 21:45:11 »
0

:O

wow awesome! Thanks a lot for this ^^

Plus no more need for abusing the MirageOs 1.0/1.1 ungroup rename glitch to rename your program to something else than LOL.8xp now ^^, altough Quigibo is gonna add compiling under different name/shell in the future
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
SirCmpwn
Guest
« Reply #143 on: 21 March, 2010, 21:48:05 »
0

wow awesome! Thanks a lot for this ^^

Sure thing!
Logged
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 08:32:53
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5645


Total Post Ratings: +589

View Profile
« Reply #144 on: 21 March, 2010, 21:51:46 »
0

Nice! Thats very useful until Quigibo can get out the official version.  Will this interfere with any of the L1-L6 ram areas?
Logged

SirCmpwn
Guest
« Reply #145 on: 21 March, 2010, 21:54:09 »
0

Nice! Thats very useful until Quigibo can get out the official version.  Will this interfere with any of the L1-L6 ram areas?

No.  The outputted code is never run.  It's a header, what it looks like is this:
ret      ; Return to the TIOS, because it shouldn't run a mirage program
01       ; MirageOS ID
Icon
Description
0
The icon is taken from the graph screen, converted to hex and copied in.  The description is converted to hex (supported characters are A-Z, a-z, and [space]), and copied in.  MirageOS skips past all this to the first line of your code.  All this does is places some data into your program for MirageOS to read.
Logged
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 08:32:53
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5645


Total Post Ratings: +589

View Profile
« Reply #146 on: 21 March, 2010, 22:12:05 »
0

true, but does Mirage use any of the same safe areas that Axe uses?
Logged

calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: Today at 07:09:04
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2737


Total Post Ratings: +376

View Profile
« Reply #147 on: 21 March, 2010, 22:37:18 »
+1

true, but does Mirage use any of the same safe areas that Axe uses?
I think StatVars holds Mirage's interrupt vector. To disable this, you might want to put Asm(ED56) after the header to make it use the TI-OS interrupt instead.
Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
ztrumpet
The Rarely Active One
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: 11 June, 2013, 05:10:51
Date Registered: 08 November, 2009, 21:10:12
Location: Michigan
Posts: 5688


Total Post Ratings: +360

View Profile
« Reply #148 on: 22 March, 2010, 00:24:26 »
0

Excellent routine SirCmpwn! Grin

true, but does Mirage use any of the same safe areas that Axe uses?
I think StatVars holds Mirage's interrupt vector. To disable this, you might want to put Asm(ED56) after the header to make it use the TI-OS interrupt instead.
Really, that's all?  Then why do Celtic III and xLib mess with Mirage so much?
Logged

_player1537
Guest
« Reply #149 on: 22 March, 2010, 00:38:44 »
0

I might be mistaken, but I believe that MOS uses one of the safe ram spots to hold the program lists, for speed.
Logged
Pages: 1 ... 8 9 [10] 11 12 ... 42   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.54 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.