Re: A83: Plain Jump


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

Re: A83: Plain Jump




Here's the tutorial:
------------------------------------------------
Introduction.
Oh, everything is possible with ASM — and I thought I'd kick off my new
tutorials with a program-creating program!

Symbol Table?
The symbol table is (as far as my understanding goes…) is a data structure
in the Ti-83's memory that stores the values of the various system
variables — lists, matrices, strings, programs, real/complex variables,
etc.  To use these things in ASM, you have to find the memory addresses in
the symbol table by searching by name.  Each type of variable has a certain
value that defines what it is — for example, 05h is a program, 06h is a
protected program.

Tokens?
Tokens are hard to explain — they're merely equates that represent various
things on the Ti.  For example, $5F represents the "prgm(" character on the
Ti.  Another example, tPic9 (pre-defined equate in tokens.inc) stands for
the Pic9 character.  You'll understand better once you've written your
program.

New Commands.
_createprog		- Creates the program.
_chkfindsym		- Checks symbol table for a given symbol.

ldir			- Load, increment, repeat.

Note that romcalls with text in blue are undocumented calls that aren't in
ti83asm.inc.  We have to equate them in our programs.


Code.

This program will create one ASM program, and the corresponding BASIC
program to run the ASM program…cool, eh?

...the standard start, plus...

.LIST

_createprog .equ 448Ah		; Makes things easier for us.
tprgm       .equ $5F		; Wasn't defined in tokens.inc
PROGOBJ .equ 05h		; Our variable type.

.org 9327h

  call _clrLCDFull  ; Clear screen.
  call _homeup      ; Home up.
  ld   hl,create
  call _puts
  call _newline
  ld   hl,asmcreate
  call _puts
  call _zerooop1    ; Set Op1 to zero
  ld hl,progname1   ; the name of the prog
  ld de,op1         ; copy it to op1
  ld bc,7           ; 7 chars in name

  ldir              ; do the copying
  call _chkfindsym  ; look it up
  call nc,_delvar   ; if it is there delete it (to keep things clean)
  ld hl,17          ; length of program (in bytes)
  call _createprog  ; create it
  inc de            ; skip 1st length byte
  inc de            ; skip 2nd length byte
  ld hl,prog1       ; program data
  ld bc,17          ; program data length
  ldir              ; copy data

  call _newline
  ld   hl,basiccreate
  call _puts

  call _zerooop1    
  ld hl,progname2   ; the name of the prog
  ld de,op1         ; copy it to op1
  ld bc,8           ; 8 chars in name
  ldir              ; do the copying
  call _chkfindsym  ; look it up
  call nc,_delvar   ; if it is there delete it (to keep things clean)
  ld hl,9           ; length of program (in bytes)
  call _createprog  ; create it
  inc de            ; skip 1st length byte
  inc de            ; skip 2nd length byte
  ld hl,prog2       ; program data

  ld bc,9           ; program data length
  ldir              ; copy data
  ret               ; all done!

progname1:
  .db PROGOBJ,"ZJAMES",0
prog1:
  .db "CD5547C9",tEnter
  .db tEnd,tEnter
  .db "0000",tEnter
  .db tEnd

progname2:
  .db PROGOBJ,"JAMES",0
prog2:
  .db tSendMBL,"9",tPrgm,"ZJAMES"


create:
  .db "Program Creator!",0
asmcreate:
  .db "Creating ASM...",0
basiccreate:
   .db "Creating BASIC...",0


.end
END

There's not too much that needs additional explanation.  Perhaps I should
explain LDIR a little…or perhaps even better, why doesn't Ian Graf explain,
as it was him who taught me how to do this:

"…What this does is copies the byte hl points to, to the byte de points to,
and decrements bc.  Then it increments both de and hl and repeats this
process until bc=0 (remember at each pass it decrements bc)…"

Perhaps this cleared everything up (perhaps not!)

Conclusion.

Ok, now you can create a program that creates programs!  A look a head to
what we'll be doing…I'd like to write my next tutorial on strings (based on
another one of Ian's programs!), then a look to some non-programming
tutorials, like debugging hints, emulator use.  Then perhaps we can move on
to complex numbers, and perhaps even linkport stuff.

Thanks to Ian Graf for his help!

 Related Topics.

------------------------------------------------
HTH


James Matthews (matthews@tkb.att.ne.jp)

ICQ: 7413754
http://home.att.ne.jp/gold/tomcat21/index.html
http://library.advanced.org/18242/

----------
> From: Evil Sam <evil_sam@hotmail.com>
> To: assembly-83@lists.ticalc.org
> Subject: Re: A83: Plain Jump
> Date: Tuesday, September 29, 1998 11:02 AM
> 
> 
> >There's a rom call that creates a program:
> >
> >createprog =$448A ; create program with type/name in op1 with hl bytes
> >
> >btw, I'm just too lazy to make an editor for my programs hehe
> >
> >Joe Wingbermuehle
> >http://www.usmo.com/~joewing/
> >
> 
> 
>    What do you mean by name/type? Like this?:
> CreateProg:
>  ld     de,NameProg
>  ld     (OP1),de
>  ld     hl, 260
>  jp   $448a
> 
> NameProg:
>  .db "planlvl1",0
> 
>    That doesn't work. Is there a certain way I need to load the name 
> into OP1?
> 
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com