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

  1. *******************************************************
  2. *                        *
  3. * Apple II 8-bit runtime sample exerciser.        *
  4. * Copyright (C) 1989 Apple Computer.        *
  5. *                        *
  6. * Written by Eric Soldan, Apple II DTS        *
  7. *                        *
  8. *******************************************************
  9.  
  10.         include    'sys.equ'
  11.         include    'app.config'
  12.         include    'rt.externs'
  13.         include    'rt.macros'
  14.  
  15. *********************************************
  16.  
  17. main        PROC
  18.         export    strlens, maxstrlens, strlocs
  19.  
  20.         jmp    main0
  21.  
  22. strlens        ds.b    numstrings
  23. maxstrlens    dc.b    maxstr1, maxstr2
  24. strlocs        dc.w    str1loc, str2loc
  25.  
  26. main0        jsr    $C300        ;Initialize 80-col screen.
  27.         _rtcout    #13
  28.         jsr    home
  29.  
  30. main1        lda    #0        ;Clear the variable space.
  31.         tax            ;This application does not
  32. @clearvars    sta    vs,x        ;need to variables to be
  33.         inx            ;pre-cleared.
  34.         bne    @clearvars
  35.  
  36. ******************
  37.  
  38.         _rtreset
  39.         _hibitchrs
  40.  
  41.         _write    '8-bit sample application demonstrating ',\
  42.             'macros and runtime.',13,\
  43.             'Copyright (C) 1989 by Apple Computer.'
  44.  
  45.         _signed
  46.         _write    13,13,13,13,'  Testing signed output:  '
  47.         _decout    #-1
  48.         _unsigned
  49.         _write    13,'Testing unsigned output:  '
  50.         _decout    #-1
  51.  
  52.         _write    13,13,'  Testing 1-byte decimal output:  '
  53.         _decoutl    #-1
  54.         _write    13,'Testing variable decimal output:  '
  55.         _set    var1,#123
  56.         _vdecout
  57.  
  58.         _write    13,13,'           hexpad default is to pad with 0''s:  '
  59.         _vhexout
  60.         _hexnopad
  61.         _write    13,'       Testing 2-byte hex output with no pad:  '
  62.         _hexout    #123
  63.         _hexpad    #32
  64.         _write    13,'Testing 2-byte hex output padded with spaces:  '
  65.         _hexout    #123
  66.  
  67.  
  68.         _hexpad    #'0'
  69.         _writecr
  70.         _write    13,'   Testing 1-byte hex output padded with 0''s:  '
  71.         _hexoutl    #15
  72.         _hexnopad
  73.         _write    13,'       Testing 1-byte hex output with no pad:  '
  74.         _hexoutl    #15
  75.         _hexpad    #32
  76.         _write    13,'Testing 1-byte hex output padded with spaces:  '
  77.         _hexoutl    #15
  78.         
  79.         jsr    nextPage
  80.  
  81.         _write    'Testing _addvar:  1234+5678='
  82.         _set    var2,#5678
  83.         _set    var1,#1234
  84.         _addvar    ,var2
  85.         _vdecout
  86.         _write    13,'  Testing _addl:  +123='
  87.         _addl    ,#123
  88.         _vdecout
  89.         _write    13,'   Testing _add:  +456='
  90.         _add    ,#456
  91.         _vdecout
  92.  
  93.         _write    13,13,'Testing _subvar:  5678-1234='
  94.         _set    var2,#1234
  95.         _set    var1,#5678
  96.         _subvar    ,var2
  97.         _vdecout
  98.         _write    13,'  Testing _subl:  -123='
  99.         _subl    ,#123
  100.         _vdecout
  101.         _write    13,'   Testing _sub:  -456='
  102.         _sub    ,#456
  103.         _vdecout
  104.  
  105.         _write    13,13,'Testing _mulvar:  12*345='
  106.         _set    var2,#345
  107.         _set    var1,#12
  108.         _mulvar    ,var2
  109.         _vdecout
  110.         _write    13,'  Testing _mull:  *6='
  111.         _mull    ,#6
  112.         _vdecout
  113.         _write    13,'   Testing _mul:  *789='
  114.         _mul    ,#789
  115.         _vdecout
  116.         _write    '   (Overflow -- loss of high-order bytes.)'
  117.  
  118.         _write    13,13,'Testing _divvar:  65432/23='
  119.         _set    var2,#23
  120.         _set    var1,#65432
  121.         _divvar    ,var2
  122.         _set    remainder
  123.         _vdecout    var1
  124.         _write    '  (Remainder='
  125.         _vdecout    remainder
  126.         _rtcout    #')'
  127.         _write    13,'  Testing _divl:  /34='
  128.         _divl    var1,#34
  129.         _set    remainder
  130.         _vdecout    var1
  131.         _write    '         (Remainder='
  132.         _vdecout    remainder
  133.         _rtcout    #')'
  134.         _write    13,'   Testing _div:  /321='
  135.         _div    var1,#321
  136.         _set    remainder
  137.         _vdecout    var1
  138.         _write    '         (Remainder='
  139.         _vdecout    remainder
  140.         _rtcout    #')'
  141.  
  142.         jsr    nextPage
  143.  
  144.         _set    var1,#345
  145.         _set0    var1
  146.         _write    'Testing _set0:  '
  147.         _vdecout
  148.         _set    var2,#2
  149.         _var    var1
  150.         _varcpy    ,var2
  151.         _write    13,'Testing _var and _varcpy (2 means good):  '
  152.         _vdecout
  153.         _set    var1,#345
  154.         _setl    ,#123
  155.         _write    13,'Testing _setl (123 means good):  '
  156.         _vdecout
  157.  
  158.         _write    13,13,'Testing _setvars:  '
  159.         _setvars    var1,#123,var2,#456,var3,#789
  160.         _vdecout    var1
  161.         _rtcout    #','
  162.         _vdecout    var2
  163.         _rtcout    #','
  164.         _vdecout    var3
  165.  
  166.         _write    13,13,'  Testing _maxswap (signed):  '
  167.         _set    var1,#-123
  168.         _signed
  169.         _maxswap    var1,var2
  170.         _vdecout
  171.         _rtcout    #','
  172.         _vdecout    var2
  173.         _write    13,'Testing _minswap (unsigned):  '
  174.         _unsigned
  175.         _minswap    var1,var2
  176.         _signed
  177.         _vdecout
  178.         _rtcout    #','
  179.         _vdecout    var2
  180.         _unsigned
  181.  
  182.         _write    13,13,'Testing _vsgncmp:  -123<456?:  '
  183.         _setvars    var1,#-123,var2,#456
  184.         _vsgncmp    var1,var2
  185.         bcc    @a
  186.         _write    'no'
  187.         jmp    @b
  188. @a        _write    'yes'
  189. @b        _write    13,'   Testing _vcmp:  -123<456?:  '
  190.         _vcmp    var1,var2
  191.         bcc    @c
  192.         _write    'no'
  193.         jmp    @d
  194. @c        _write    'yes'
  195. @d        _write    13,' Testing _sgncmp:  -123<456?:  '
  196.         _sgncmp    var1,#456
  197.         bcc    @e
  198.         _write    'no'
  199.         jmp    @f
  200. @e        _write    'yes'
  201. @f        _write    13,'    Testing _cmp:  -123<456?:  '
  202.         _cmp    var1,#456
  203.         bcc    @g
  204.         _write    'no'
  205.         jmp    @h
  206. @g        _write    'yes'
  207. @h
  208.  
  209.         _readend    #0
  210.         _restore    #strdata
  211.         _readstr    str1
  212.         _prstr
  213.         _readstr    str2
  214.         _strval
  215.         _decout
  216.  
  217.         _readstr    str1
  218.         _prstr
  219.         _midstrval str2,#2
  220.         _decout
  221.  
  222.         _rtcout      #13
  223.         _readstr   str1
  224.         _prleftstr str1,#10
  225.         _prmidstr  str1,#10,#5
  226.         _prmidstr  str1,#15,#255
  227.  
  228.         _rtcout     #13
  229.         _readstr    str1
  230.         _leftstrcpy str2,str1,#15
  231.         _prstr
  232.         _midstrcpy  ,str1,#15,#5
  233.         _prstr
  234.         _midstrcpy  ,str1,#20
  235.         _prstr
  236.  
  237.         _rtcout    #13
  238.         _readstr    str1
  239.         _strcpy    str2,str1
  240.         _prstr
  241.  
  242.         _rtcout     #13
  243.         _readstr    str2
  244.         _readstr    str1
  245.  
  246.         _leftstrcat str2,str1,#10
  247.         _midstrcat  ,str1,#10,#5
  248.         _midstrcat  ,str1,#15
  249.         _prstr
  250.  
  251.         _rtcout    #13
  252.         _readstr    str1
  253.         _readstr    str2
  254.  
  255.         _strcat    str1,str2
  256.         _prstr
  257.  
  258.         jsr    nextPage
  259.  
  260.         _readstr    str1
  261.         ldy    #0
  262. @loop        cpy    strlens+str1
  263.         beq    @brkloop
  264.         tya
  265.         pha
  266.         _strchr
  267.         _rtcout
  268.         pla
  269.         tay
  270.         iny
  271.         bne    @loop
  272. @brkloop
  273.  
  274.         _litstr    str1,13,'Testing _litstr.'
  275.         _prstr
  276.         _write    13,'Testing _strloc:  str1 is at $'
  277.         _strloc    str1
  278.         _hexout
  279.  
  280.         _write    13,13,'Testing _rndseed:  value passed is:  $'
  281.         _hexnopad
  282.         _hexout    *rndl
  283.         _rndseed    *rndl
  284.         _write    13,13,'Testing _random (200 numbers from 0 to 99):',13,13
  285.         ldx    #10
  286. @loopx        stx    @tempx
  287.         ldy    #20
  288. @loopy        sty    @tempy
  289.         _random    #100        ;This random generator can not generate
  290.         _decout            ;a zero value.  This is okay, since you
  291.         lda    #','        ;can't declare a limit in 2 bytes which
  292.         ldy    @tempy        ;would give you this range.  (To get a
  293.         dey            ;high-end value of 65535, you would have
  294.         bne    @i        ;to have a limit of 65536.
  295.         lda    #13        ;Adjustments for the algorithm not
  296. @i        _rtcout            ;generating a 0 value have been made.
  297.         ldy    @tempy        ;1 is subtracted from the value, thus
  298.         dey            ;moving the problem value from 0 to 65535.
  299.         bne    @loopy        ;Since there is a limit on the 65535 value
  300.         ldx    @tempx        ;anyway, due to not being able to declare
  301.         dex            ;a limit or 65536, this works rather well.
  302.         bne    @loopx
  303.  
  304.         jsr    nextPage
  305.  
  306.         _write    13,'Testing array handling.'
  307.         _write    13,'The array is 2x512x2x4 words.'
  308.  
  309.         _array    #$4000,w,#2,#512,#2,#4
  310.  
  311.         _index    #1,#379,#1
  312.         _set    var1,#1234
  313.         _putw    ,#3
  314.  
  315.         _index    ,#73
  316.         _set    var1,#5678
  317.         _putw    ,#4
  318.  
  319.         _write    13,13,'array(1,379,1,3)='
  320.         _index    ,#379,#1
  321.         _getw    var1,#3
  322.         _vdecout
  323.  
  324.         _write    13,'array(1,73,0,4)='
  325.         _index    ,#73
  326.         _getw    var1,#4
  327.         _vdecout
  328.  
  329.         jsr    nextPage
  330.  
  331.         jmp    main1
  332. @tempx        dc.b    0
  333. @tempy        dc.b    0
  334.  
  335.  
  336. strdata        _cstr    13,13,'Testing _readend, _restore, ',\
  337.             '_readstr, and _strval:  '
  338.         _cstr    '12345'
  339.         _cstr    13,'Testing _midstrval:  '
  340.         _cstr    'Testing _prleftstr and _prmidstr.'
  341.         _cstr    'Testing _leftstrcpy and _midstrcpy.'
  342.         _cstr    'Testing _strcpy.'
  343.         _cstr    0,'Testing _leftstrcat and _midstrcat.'
  344.         _cstr    'Testing '
  345.         _cstr    '_strcat.'
  346.         _cstr    13,'Testing _strchr.'
  347.  
  348.  
  349. nextPage        lda    #22
  350.         sta    cv
  351.         _write    13,'  <<< Press any key to go on (or ESC to quit). >>>'
  352.         bit    $C010
  353. @a        inc    rndl
  354.         bne    @b
  355.         inc    rndh
  356. @b        lda    $C000
  357.         bpl    @a
  358.         bit    $C010
  359.         cmp    #$9B
  360.         beq    @quit
  361.         jmp    home
  362. @quit        jsr    home
  363.         jsr    mli
  364.         dc.b    $65
  365.         dc.w    @quitlist
  366. @quitlist    dc.b    4
  367.         dc.w    0,0,0
  368.  
  369.         endp
  370.  
  371.         END
  372.  
  373.