Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: bobbean on September 02, 2013, 05:27:22 pm

Title: Patching the OS
Post by: bobbean on September 02, 2013, 05:27:22 pm
I was wondering how I would write a simple patch, for example enabling lowercase letters or writing a hotkey (ex. mirage's on+apps). I know some assembly, so I won't be starting from scratch.
Title: Re: Patching the OS
Post by: Sorunome on September 02, 2013, 05:29:20 pm
You could just use a existing app like MOS, or, what is far more awesome, DCS to do that.
Title: Re: Patching the OS
Post by: bobbean on September 02, 2013, 05:34:03 pm
Thanks, but I want to do it myself and learn how everything works.
Title: Re: Patching the OS
Post by: Sorunome on September 02, 2013, 05:35:48 pm
http://answers.yahoo.com/question/index?qid=20100105162418AAR1i7Z
Quote
If you don't have MirageOS, you can switch on the functionality by making a hex code assembly program. Just create a new program and enter the following as code:
:AsmPrgmFDCB24DEC9

AsmPrgm can be found in the Catalog.

Make sure you type it in EXACTLY as shown; one mistake will cause your calculator to crash.
To run this program, you have to use the Asm( token which can be found in the Catalog, [2nd][0]. Asm(prgmLOWERC should be similar to what it would look like.

If you're interested in some more hex codes, check out http://tibasicdev.wikidot.com/hexcodes
Does that help?
Title: Re: Patching the OS
Post by: bobbean on September 02, 2013, 06:30:04 pm
Haha kinda, thanks for helping but what I want is to learn how to write that or learn exactly how it works.
Title: Re: Patching the OS
Post by: Hooloovoo on September 02, 2013, 06:35:56 pm
That is just setting a flag which tells the OS to use lowercase.
Title: Re: Patching the OS
Post by: AssemblyBandit on September 02, 2013, 09:13:57 pm
I would probably use a hook to check for your hotkey ( http://wikiti.brandonw.net/index.php?title=83Plus:Hooks:9B84 ) or maybe use the font hook. ( http://wikiti.brandonw.net/index.php?title=83Plus:Hooks:9B9C ) and like fortytwo mentioned, set the lowercase flag. (I can't find it on wikiti, but I know it exists :( )
Title: Re: Patching the OS
Post by: Xeda112358 on September 03, 2013, 12:34:00 am
Since the title of the thread is "patching the OS," I am assuming you actually want to modify the OS itself instead of simply using what the OS has to offer. In that, thepenguin77 is pretty knowledgeable. Really, it would most likely amount to toggling a handful of bits in the OS (bits, not even whole bytes would need to be edited). I haven't dabbled in that yet, but to expand a little on what was said before...

The hex code FDCB24DEC9 translates to:
Code: [Select]
     set 3,(iy+24h)
     ret
When you say you have assembly experience, I am not sure if you mean specifically Z80, or other assembly languages, but basically, the OS reserves the index register IY for its own use. It points tot he start of the system flags, and as its name implies, flags can thus be referenced as an offset from IY. so IY+0 would be the first byte, IY+1 would be the second, et cetera. Almost all of the instructions that use the register pair HL can use one of the two index registers (the other is IX). So for example, ld a,(iy+7) would load the contents 7 bytes ahead of where IY points into a.

The instructions starting with set res and bit allow you to modify or read an individual bit of an 8-bit register or the byte of ram pointed to by the register pair HL. SO this gives you b,c,d,e,h,l,(hl),a. With these, you can use an index register in place of (hl) allowing you to use (ix+const). Taking a look at the code above, again, we have:

Code: [Select]
     set 3,(iy+24h)
Since IY should be pointing to the flags, the OS keeps the offset 24h as the byte with the flag controlling lowercase mode. In particular, it is bit 3 at offset 24h that is the appropriate flag. You don't have to memorize the flags and offsets too much, though, if you don't want to. The ti83plus.inc (http://www.brandonw.net/calcstuff/ti83plus.txt) file has defines and equates that will let you do something like:
Code: [Select]
     set lwrCaseActive,(iy+appLwrCaseFlag)

The links that Assemblybandit provided are to an excellent resource if you want to learn how the OS works. Hooks were intended to provide a safe way to modify the actions of or update functionality of the OS without actually needing to go in and permanently edit it.

I hope  this helps!
Title: Re: Patching the OS
Post by: bobbean on September 03, 2013, 11:58:15 pm
Wow, thank you so much guys, that is exactly what I was looking for. I'll take a look at those links and try figuring everything out (and yes, I do have some experience with the z80 processor). I'm not used to people being so helpful, thanks!
Title: Re: Patching the OS
Post by: Lionel Debroux on September 04, 2013, 01:44:48 am
And if you really want to make an OS patch for the 83+/84+ (say, because some behaviour can't be changed through a hook), FYI, we've been able to sign arbitrary OS with TI's private key since 2009 (because a single person at first, then a collective effort, factored the relevant 512-bit RSA public keys), and we can still bend to our will recent 84+ models which validate a signature in the OS using a 2048-bit RSA key.
Title: Re: Patching the OS
Post by: TIfanx1999 on September 04, 2013, 02:49:23 am
I'm not used to people being so helpful, thanks!

Hey, that's just how we roll here. ;) Welcome to onmimaga. You should head over and <a href=http://www.omnimaga.org/index.php?board=10.0>introduce yourself.</a>
Title: Re: Patching the OS
Post by: thepenguin77 on September 04, 2013, 09:43:07 am
Well, you may have titled the page improperly because you don't actually need to patch the OS. But when the time finally comes and you want to patch the OS, I did in fact make a patcher. (Physically patching the OS sucks. It takes so much code to make such a small change, even if you know exactly what you want to change).

And while we're at it, I might as well link to my guide on hooks (http://wikiti.brandonw.net/index.php?title=83Plus:OS:Hooks) since this information is available literally nowhere.
Title: Re: Patching the OS
Post by: TIfanx1999 on September 04, 2013, 09:55:18 am
By the way, if you feel it's an appropriate place, you can upload the guide in our <a href=http://www.omnimaga.org/index.php?action=articles;cat=11>tutorials section.</a>
Title: Re: Patching the OS
Post by: Lionel Debroux on September 04, 2013, 12:58:51 pm
On the TI-Z80 series, besides thepenguin77's patcher, PolyPatch84 is a set of ready-made patches on the computer side.
On the TI-68k series, there's my tiosmod+amspatch, also on the computer side, to be followed by Rabbitsign.