home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol090 / systest3.mac < prev    next >
Encoding:
Text File  |  1984-04-29  |  3.0 KB  |  149 lines

  1. ;
  2. ;  PROGRAM:  SYSTEST3
  3. ;  AUTHOR:  Richard Conn
  4. ;  PURPOSE:  This program demonstrates the EVAL routines and the Math routines
  5. ;        within SYSLIB
  6. ;
  7.  
  8. ;
  9. ;  Externals
  10. ;
  11.     EXT    ADDHD    ; HL = HL + DE
  12.     EXT    SUBHD    ; HL = HL - DE
  13.     EXT    NEGH    ; HL = NEGATE OF HL
  14.     EXT    MULHD    ; HL = HL * DE
  15.     EXT    DIVHD    ; HL = HL / DE
  16.     EXT    ANDHD    ; HL = HL AND DE
  17.     EXT    ORHD    ; HL = HL OR DE
  18.     EXT    XORHD    ; HL = HL XOR DE
  19.     EXT    SHFTRH    ; HL = HL shifted right one bit position
  20.     EXT    SHFTLH    ; HL = HL shifted left one bit position
  21.     EXT    ROTRH    ; HL = HL rotated right one bit position
  22.     EXT    ROTLH    ; HL = HL rotated left one bit position
  23.  
  24.     EXT    PRINT    ; Print String
  25.     EXT    BBLINE    ; Input Line Editor
  26.     EXT    EVAL    ; Number Evaluator
  27.     EXT    PHLDC    ; Print HL as up to 5 decimal chars
  28.     EXT    PHL4HC    ; Print HL as 4 Hex chars
  29.  
  30. ;
  31. ;  ASCII Char defns
  32. ;
  33. cr    equ    0dh
  34. lf    equ    0ah
  35.  
  36. ;
  37. ;  Print Banner
  38. ;
  39.     call    print
  40.     db    'SYSTEST3 -- Math Routines and Evaluation Demo',0
  41.  
  42. ;
  43. ;  This is the main loop and a prompt to the user.
  44. ;
  45. loop:
  46.     call    print
  47.     db    cr,lf,'Input Two Numbers, Separated by a Comma (<CR> to Stop)'
  48.     db    ' -- ',0
  49.     call    bbline    ; get user input
  50.     ora    a    ; no input if A=0
  51.     rz        ; return to Operating System
  52.     call    eval    ; evaluate the first number (which is pted to by HL)
  53.     xchg        ; place number in HL
  54.     shld    num1    ; save it away as 1st number
  55.     xchg        ; restore pointer to comma after number in HL
  56.     inx    h    ; skip comma
  57.     call    eval    ; evaluate the 2nd number (returned in DE)
  58.  
  59. ;
  60. ;  Through the rest of this loop, DE contains the 2nd number.  Note that none
  61. ;  of the routines affect it.
  62. ;
  63.     call    print
  64.     db    cr,lf,'First Number is ',0
  65.     lhld    num1    ; get and print first number
  66.     call    phldc    ; print in decimal
  67.     call    print
  68.     db    ' in Decimal or ',0
  69.     call    phl4hc    ; print in hex
  70.     call    print
  71.     db    ' in Hex',cr,lf,0
  72.     call    print
  73.     db    'The Second Number is ',0
  74.     xchg        ; get 2nd number into HL
  75.     call    phldc    ; print in decimal
  76.     call    print
  77.     db    ' in Decimal or ',0
  78.     call    phl4hc    ; print in hex
  79.     call    print
  80.     db    ' in Hex',cr,lf,0
  81.     xchg        ; save 2nd number in DE for rest of loop
  82.     call    print
  83.     db    cr,lf,'Sum = ',0
  84.     lhld    num1    ; get first number again
  85.     call    addhd    ; HL = HL + DE
  86.     call    phldc    ; print sum
  87.     call    print
  88.     db    '  Difference = ',0
  89.     lhld    num1    ; get first number (since destroyed by ADDHD)
  90.     call    subhd    ; ... and so on ...
  91.     call    phldc    ; print difference
  92.     call    print
  93.     db    '  Product = ',0
  94.     lhld    num1
  95.     call    mulhd
  96.     call    phldc    ; print product
  97.     call    print
  98.     db    '  Quotient = ',0
  99.     lhld    num1
  100.     call    divhd
  101.     call    phldc    ; print quotient
  102.     call    print
  103.     db    cr,lf,'  Negative of First Argument = ',0
  104.     lhld    num1
  105.     call    negh
  106.     call    phldc    ; print negative
  107.     call    print
  108.     db    cr,lf,'AND = ',0
  109.     lhld    num1    ; get first number
  110.     call    andhd
  111.     call    phl4hc
  112.     call    print
  113.     db    '  OR = ',0
  114.     lhld    num1
  115.     call    orhd
  116.     call    phl4hc
  117.     call    print
  118.     db    '  XOR = ',0
  119.     lhld    num1
  120.     call    xorhd
  121.     call    phl4hc
  122.     call    print
  123.     db    cr,lf,'First Argument:  SHIFT L = ',0
  124.     lhld    num1
  125.     call    shftlh
  126.     call    phl4hc
  127.     call    print
  128.     db    '  SHIFT R = ',0
  129.     lhld    num1
  130.     call    shftrh
  131.     call    phl4hc
  132.     call    print
  133.     db    '  ROT L = ',0
  134.     lhld    num1
  135.     call    rotlh
  136.     call    phl4hc
  137.     call    print
  138.     db    '  ROT R = ',0
  139.     lhld    num1
  140.     call    rotrh
  141.     call    phl4hc
  142.     jmp    loop
  143.  
  144. num1:    ds    2    ; first number
  145.  
  146.     db    0
  147.  
  148.     end
  149.