[A83] Re: Selfmodifying code


[Prev][Next][Index][Thread]

[A83] Re: Selfmodifying code




> > Hi again! :)
> >
> > Lately I have written some self-modifying code, and it got me thinking
> > a bit about how ASM-programs actually works on the TI83, and I also
> > came to the conclusion that I didn't know squat about it!
> >
> > Say I have a 'normal' ASM-program, it seems to be stored in some ASCII
> > hex format, it looks like this when I do prg/edit:
> > 0A000BC000...etc
> > Now, this can't be run in the current state, so I guess that when you
> > do a send(9prgName it 'unpacks' it to some other memory area, right?
> > But if you have a program that is 20k (in the text format), then you
> > would need approximately 10k additional RAM to unpack it to. Is this
> > the way it works? Then the 'real' program can't be more than about
> > 8k, since this in text-format would occupy approx 16k and then you need
> > another 8k free to unpack it too? Am I totally wrong here, enlighten me!
>
>You're right...
>
>
> > Then we have 'squished' programs, that seem to be in binary format from
> > the beginning. Does the calc run them directly, and in that case, if I
> > write self-modifying code, will these mods be permanent, so that the
> > next time you start the prg it will be in the state I left it after
> > the last run?
>
>Depends on what shell you use...
>
>ZASMLOAD makes a copy of the program code, so your program can be 12k max. 
>It
>does not not support Program Write Back, so your is

You actually can write back to the program, like this:

     	ld hl,prog
     	rst 20h              ;=ld (hl) -> (hl+9) to op1
     	call _chkfindsym
; now the location of the prog is in de

prog:   .db   5,"ZSUCWELC",0

but this only writes into the prog that was copied, and
not into the actual running code, if you want to write
in the running code also, just load a value to the label
in the running prog.

  SUCKER

back in its original state
>when you execute it again.
>
>When you use a 'better' shell (ASHELL, SOS, ION, etc.) it runs the program 
>in a
>other way, supporting 'write back'... ASHELL and SOS swap the program code 
>with
>the code at 'progstart' when you execute the program, calls 'progstart', 
>and
>swap it back when it is finished (that's why you can't use external files 
>in
>these programs: VAT is temperly screwed). ION uses a complexer way to 
>execute,
>which i havn't figured out yet, to preserve the VAT.
>With those shells your program can be +/- 21kb (the shell has to run too), 
>and
>when you modify your code during execution it is indeed written back in 
>that
>state when you finish your program.
>
>


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp