home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 162_01 / comp32.mac < prev    next >
Text File  |  1985-08-21  |  3KB  |  120 lines

  1. ;    Float and long comparisons
  2.     NAME    ('COMP32')
  3.     INCLUDE DEQ.MAC
  4.  
  5. ;    AM9511 STATUS BYTE EXPANDED TO "FLAG" INTEGERS
  6. ;    All int values will be either one or zero.
  7. ;    First group is one bit flags, direct conversion (not reversed).
  8. B0CARY:: DW    0 ; Represents bit zero only.
  9. ;    If flag value = 1, then AM9511 performed
  10. ;    a carry or borrow in the previous operation.
  11. B1OFLO:: DW    0    ; 1= overflow, else 0
  12. B2UFLO:: DW    0    ; 1= underflow, else 0
  13. B3NEGL:: DW    0    ; 1= sqrt or log of neg num
  14. B4DIVZ:: DW    0    ; 1= divide by zero
  15. B5ZERO:: DW    0    ; 1= zero value result
  16. B6SIGN:: DW    0    ; 1= neg value result
  17. ;  Bit 7 of the AM9511 status byte is 'device busy/not busy'.
  18.  
  19. ; Multiple bit flags
  20. B56POS:: DW    0    ; 0= non zero pos result (bits 5,6)
  21. NOERR:: DW    0    ; 0= no error (bits 1,2,3,4)
  22. NOBITS:: DW    0    ; 0= no status bits (0 thru 6)
  23. B34ARG:: DW    0    ; 1= arg too large for pwr,e^x
  24. ;
  25. ; Reversed flags
  26. B5NZ::    DW    0    ; 1= non-zero result
  27. B6NSGN:: DW    0    ; 1= pos or zero result
  28. B56NEG:: DW    0    ; 1= greater than zero
  29.     EXTRN    CMDBYT,STATUS,CMDIO
  30.     EXTRN    FLSD.B,FLRD
  31.     .Z80
  32. FLCMP    MACRO    CPBYT,XPWRD
  33.     LD    HL,XPWRD
  34.     LD    A,CPBYT
  35.     JP    ST.C32
  36.     ENDM
  37.  
  38. ; Toolworks labels as entry points
  39. ; 'cf.' labels are compare-float operations
  40. cf.ge:: FLCMP    .FSUB,B6SIGN
  41. cf.lt:: FLCMP    .FSUB,B6NSGN
  42. cf.eq:: FLCMP    .FSUB,B5NZ
  43. cf.ne:: FLCMP    .FSUB,B5ZERO
  44. cf.gt:: FLCMP    .FSUB,B56POS
  45. cf.le:: FLCMP    .FSUB,B56NEG
  46.  
  47. ; 'cl.' labels are compare-long operations
  48. cl.ge:: FLCMP    .LSUB,B6SIGN
  49. cl.lt:: FLCMP    .LSUB,B6NSGN
  50. cl.eq:: FLCMP    .LSUB,B5NZ
  51. cl.ne:: FLCMP    .LSUB,B5ZERO
  52. cl.gt:: FLCMP    .LSUB,B56POS
  53. cl.le:: FLCMP    .LSUB,B56NEG
  54.  
  55. SAVHL:    DW    0
  56.  
  57. ST.C32: LD    (SAVHL),HL
  58.     LD    (CMDBYT),A
  59.  
  60.     EQUJPS    ,FLSD.B,FLRD,CMDIO,CLXPAN
  61.  
  62. CLXPAN: CALL    XPAND1
  63.     LD    HL,(SAVHL)
  64.     LD    A,(HL)
  65.     DEC    A
  66.     RET
  67. ;
  68. ; The following routine refreshes the 14 integers declared
  69. ; at the beginning of this file.
  70. ;
  71. XPAND1::
  72.     LD    HL,B0CARY    ; initialize at B0CARY
  73.     LD    B,10D        ; set up, 10 loops
  74.     LD    IY,BITS
  75.     LD    A,(STATUS)    ; from most recent device operation
  76.     LD    D,A
  77.     CALL    XLUP
  78.     LD    (HL),0
  79.     LD    A,D
  80.     AND    00011000B    ; bits 3 & 4, BOTH
  81.     CP    00011000B
  82.     JR    NZ,ELSE2
  83.     LD    (HL),1
  84.     LD    HL,B3NEGL
  85.     XOR    A
  86.     LD    (HL),A
  87.     INC    HL
  88.     INC    HL
  89.     LD    (HL),A
  90. ELSE2:
  91.     LD    HL,B5NZ
  92.     LD    B,2
  93.     LD    IY,BITS+5
  94.     LD    A,D
  95.     CPL
  96.     LD    D,A
  97.     CALL    XLUP
  98.     LD    A,(B56POS)
  99.     XOR    1
  100.     LD    (B56NEG),A
  101.     RET
  102. XLUP:    LD    C,(IY+0)
  103.     INC    IY
  104.     LD    (HL),0
  105.     LD    A,D
  106.     AND    C
  107.     JR    Z,ELSE1
  108.     LD    (HL),1
  109. ELSE1:    INC    HL
  110.     INC    HL
  111.     DJNZ    XLUP
  112.     RET
  113.  
  114. BITS:    DB    1,2,4,8,16,32,64
  115.     DB    01100000B
  116.     DB    00011110B
  117.     DB    01111111B
  118.     .8080
  119.     END
  120.