home *** CD-ROM | disk | FTP | other *** search
/ develop, the CD; issue 1 / Apple_Develop_1989.bin / dynamo / rt.macros < prev    next >
Text File  |  1989-12-10  |  35KB  |  1,472 lines

  1. *******************************************************
  2. *                        *
  3. * DYNAMO                        *
  4. *                        *
  5. * Apple II 8-bit runtime macros.            *
  6. * Copyright (C) 1989 Apple Computer.        *
  7. *                        *
  8. * Written by Eric Soldan, Apple II DTS        *
  9. *                        *
  10. *******************************************************
  11.  
  12. * These macros are interfaces for the runtime routines associated with them.
  13. * The runtime routines handle up to 128 integer variables, and up to 256
  14. * strings.  The integer functions are simple add,sub,mul,div, and others.
  15. * These others include mass-initialization, min, max, print decimal, etc.
  16. * The string functions are most of what is available in AppleSoft, in
  17. * various forms.  There is also support for multi-dimension arrays.
  18.  
  19. * The principle of the runtime routines is that the xreg holds a destination
  20. * variable number (for ints: 0-254, for strings: 0-255).  All runtimes preserve
  21. * the xreg, therefore, you can do multiple operations to a single variable
  22. * without having to reload the xreg.  The values that are used on the xreg
  23. * variable (the source data), is one of 3 forms for integers:
  24. *    1. 1-byte value
  25. *    2. 2-byte value
  26. *    3. 2-byte integer variable.
  27. * 1-byte values are placed in the acc.  2-byte values are placed in the acc,y
  28. * (acc=lo, y=hi).  2-byte integer variables have the variable number placed in
  29. * the yreg.  (The yreg is not preserved by the runtime routines.)
  30. * Once the source data is loaded (in acc, acc-y, or y), the proper call to the
  31. * runtime routines is made.  The 'proper' routine is based on the type of data
  32. * the source is.  (If the source is a variable, and we are adding, the macro
  33. * will call the addvar routine.)
  34.  
  35. * Strings are also referenced by number.  There are 3 tables for strings:
  36. *    1. String length table.
  37. *    2. Max string length table.
  38. *    3. Pointer table.
  39. * So, each string takes up four bytes, plus however long the max string length
  40. * is.  Having the pointer allows the program to point into memory that was
  41. * never loaded or initialized.  This can save time loading the application from
  42. * disk.  The string routines will never overwrite the buffer space alloced for
  43. * them.  The string will be truncated.  So, you can append strings without
  44. * worry about clobbering memory.
  45.  
  46.  
  47. *****************************************************************
  48. *****************************************************************
  49. *****************************************************************
  50.  
  51.  
  52. * These macros are called by other macros in this file.
  53.  
  54.     MACRO
  55.     acorm    &op
  56.     if    &substr(&op,1,1)='#' goto .imm
  57.     if    &substr(&op,1,1)<>'*' then
  58.     aerror    'non-variable parameter must be preceeded by a # or *'
  59.     mexit
  60.     endif
  61.     lda    &substr(&op,2,999)
  62.     mexit
  63. .imm    lda    #<&substr(&op,2,999)
  64.     mend
  65.  
  66.     MACRO
  67.     xcorm    &op
  68.     if    &substr(&op,1,1)='#' goto .imm
  69.     if    &substr(&op,1,1)<>'*' then
  70.     aerror    'non-variable parameter must be preceeded by a # or *'
  71.     mexit
  72.     endif
  73.     ldx    &substr(&op,2,999)
  74.     mexit
  75. .imm    ldx    #<&substr(&op,2,999)
  76.     mend
  77.  
  78.     MACRO
  79.     axcorm    &op
  80.     if    &substr(&op,1,1)='#' goto .imm
  81.     if    &substr(&op,1,1)<>'*' then
  82.     aerror    'non-variable parameter must be preceeded by a # or *'
  83.     mexit
  84.     endif
  85.     lda    &substr(&op,2,999)
  86.     ldx    &substr(&op,2,999)+1
  87.     mexit
  88. .imm    lda    #<&substr(&op,2,999)
  89.     ldx    #>&substr(&op,2,999)
  90.     mend
  91.  
  92.     MACRO
  93.     ycorm    &op
  94.     if    &substr(&op,1,1)='#' goto .imm
  95.     if    &substr(&op,1,1)<>'*' then
  96.     aerror    'non-variable parameter must be preceeded by a # or *'
  97.     mexit
  98.     endif
  99.     ldy    &substr(&op,2,999)
  100.     mexit
  101. .imm    ldy    #<&substr(&op,2,999)
  102.     mend
  103.  
  104.     MACRO
  105.     aycorm    &op
  106.     if    &substr(&op,1,1)='#' goto .imm
  107.     if    &substr(&op,1,1)<>'*' then
  108.     aerror    'non-variable parameter must be preceeded by a # or *'
  109.     mexit
  110.     endif
  111.     lda    &substr(&op,2,999)
  112.     ldy    &substr(&op,2,999)+1
  113.     mexit
  114. .imm    lda    #<&substr(&op,2,999)
  115.     ldy    #>&substr(&op,2,999)
  116.     mend
  117.  
  118.  
  119. *****************************************************************
  120. *****************************************************************
  121. *****************************************************************
  122.  
  123.  
  124. * This macro initializes everything necessary in the runtime and runtime
  125. * macros.  It initializes global macro variables and resets everything
  126. * in the runtime so the application can resume if the user presses a reset.
  127.     MACRO
  128. &lab    _rtreset
  129. &lab    jsr    rtreset
  130.     MEND
  131.  
  132.  
  133. ***************************************
  134.  
  135.  
  136. * This macro is used to turn on the hi-bit for characters that are sent to rtcout.
  137.     MACRO
  138. &lab    _hibitchrs
  139. &lab    jsr    hibitchrs
  140.     MEND
  141.  
  142.  
  143. ***************************************
  144.  
  145.  
  146. * This macro is used to turn off the hi-bit for characters that are sent to rtcout.
  147.     MACRO
  148. &lab    _lowbitchrs
  149. &lab    jsr    lowbitchrs
  150.     MEND
  151.  
  152.  
  153. ***************************************
  154.  
  155.  
  156. * This macro is used to make sure that characters sent to rtcout are used as-is.  There
  157. * will be no modification of the hi-bit.
  158.     MACRO
  159. &lab    _regchrs
  160. &lab    jsr    regchrs
  161.     MEND
  162.  
  163.  
  164. ***************************************
  165.  
  166.  
  167. * This macro prints a character.  This character is either already in the acc
  168. * (no operand), or what is described by the operand.  The operand can either
  169. * be an absolute or a value in memory.
  170. * (acorm means load Acc with a Constant OR Memory value).
  171.     MACRO
  172. &lab    _rtcout    &op
  173. &lab
  174.     if    &op='' goto .jsr
  175.     acorm    &op
  176. .jsr    jsr    rtcout
  177.     MEND
  178.  
  179.  
  180. ***************************************
  181.  
  182.  
  183. * This macro prints ascii data following the _write macro.  The write routine
  184. * works by using the return address as a pointer to the ascii data.  The ascii
  185. * data is terminated with a 0 (C-string style).  When the write routine
  186. * encounters a 0, it sets the return address so the when an rts is executed,
  187. * it returns to the code following the 0 terminator.  As many parameters as
  188. * are desired can be passed to this routine.  If the ascii data is more than
  189. * 1 line, end it with a comma,backslash to indicate line continuation.
  190.     MACRO
  191. &lab    _write
  192. &lab    
  193.     if    &syslist[1]='' then
  194.     aerror    '_write:  must have at least one parameter'
  195.     mexit
  196.     endif
  197.     jsr    write
  198.     lcla    &i,&n
  199. &i    seta    1
  200. &n    seta    &nbr(&syslist)
  201. .a    dc.b    &syslist[&i]
  202. &i    seta    &i+1
  203.     if    &i<=&n goto .a
  204.     dc.b    0
  205.     MEND
  206.  
  207.  
  208. ***************************************
  209.  
  210.  
  211. * This macro prints a carriage return.
  212.     MACRO
  213. &lab    _writecr
  214. &lab    jsr    writecr
  215.     MEND
  216.  
  217.  
  218. ***************************************
  219.  
  220.  
  221. * This macro prints a c string pointed to by the operand.
  222.     MACRO
  223. &lab    _wrcstr    &op
  224. &lab    aycorm    &op
  225.     jsr    wrcstr
  226.     MEND
  227.  
  228.  
  229. ***************************************
  230. ***************************************
  231. ***************************************
  232.  
  233.  
  234. * This macro sets signed mode.  Printing decimal numbers is affected by this.
  235.     MACRO
  236. &lab    _signed
  237. &lab    jsr    signed
  238.     MEND
  239.  
  240.  
  241. ***************************************
  242.  
  243.  
  244. * This macro sets unsigned mode.  Printing decimal numbers is affected by this.
  245.     MACRO
  246. &lab    _unsigned
  247. &lab    jsr    unsigned
  248.     MEND
  249.  
  250.  
  251. ***************************************
  252.  
  253.  
  254. * This macro does a two's compliment on the variable.
  255.     MACRO
  256. &lab    _chngsgn
  257. &lab    jsr    chngsgn
  258.     MEND
  259.  
  260.  
  261. ***************************************
  262.  
  263.  
  264. * This macro prints a 1-byte decimal value.  This value is either already in
  265. * the acc (no operand), or what is described by the operand.  The operand can
  266. * either be an absolute or a value in memory.
  267.     MACRO
  268. &lab    _decoutl    &op
  269. &lab    
  270.     if    &op='' goto .jsr
  271.     acorm    &op
  272. .jsr    jsr    decoutl
  273.     MEND
  274.  
  275.  
  276. ***************************************
  277.  
  278.  
  279. * This macro prints a 2-byte decimal value.  This value is stored in a
  280. * variable.  The variable number is either already in the xreg (no operand),
  281. * or is determined by the operand.
  282.     MACRO
  283. &lab    _vdecout    &op
  284. &lab    
  285.     if    &op='' goto .jsr
  286.     ldx    #<&op
  287. .jsr    jsr    vdecout
  288.     MEND
  289.  
  290.  
  291. ***************************************
  292.  
  293.  
  294. * This macro prints a 2-byte decimal value.  This value is either already in
  295. * the acc,y (no operand), or what is described by the operand.  The operand
  296. * can either be an absolute or a value in memory.
  297.     MACRO
  298. &lab    _decout    &op
  299. &lab    
  300.     if    &op='' goto .jsr
  301.     aycorm    &op
  302. .jsr    jsr    decout
  303.     MEND
  304.  
  305.  
  306. ***************************************
  307.  
  308.  
  309. * This macro sets pad mode for hex.  The value is either already in the acc
  310. * (no operand), or what is described by the operand.  The operand can either
  311. * be an absolute or a value in memory.  Printing hex numbers is affected by
  312. * this.
  313.     MACRO
  314. &lab    _hexpad    &op
  315. &lab    
  316.     if    &op='' goto .jsr
  317.     acorm    &op
  318. .jsr    jsr    hexpad
  319.     MEND
  320.  
  321.  
  322. ***************************************
  323.  
  324.  
  325. * This ma