?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1.  ifndef included_xcmp
  2.  define included_xcmp
  3.  include "../common/mov.asm"
  4.  include "xsub.asm"
  5.  
  6. xcmp:
  7. ;Input: DE points to float1, HL points to float2
  8. ;Output:
  9. ;      float1 >= float2 : nc
  10. ;      float1 <  float2 : c,nz
  11. ;      float1 == float2 : z
  12. ;  There is a margin of error allowed in the lower 2 bits of the mantissa.
  13. ;
  14. ;Currently fails when both numbers have magnitude less than about 2^-16322
  15.   push hl
  16.   push de
  17.   push bc
  18.   call xcmppp;+_
  19.   pop bc
  20.   pop de
  21.   pop hl
  22.   ret
  23. xcmppp;_:
  24.   push de
  25.   ld de,xOP2
  26.   call mov10
  27.   pop hl
  28.   call mov10
  29.  
  30.   ld hl,(xOP2+8)
  31.   ld de,(xOP3+8)
  32.   or a
  33.   sbc hl,de
  34.   add hl,de
  35.   jr nc,$+3
  36.   ex de,hl
  37.   res 7,h
  38.   push hl   ;exponent
  39.   ld hl,xOP2
  40.   ld de,xOP3
  41.   ld b,h
  42.   ld c,l
  43.   call xsub
  44.   pop hl
  45.   ld de,(xOP2+8)
  46.   ld a,d
  47.   or e
  48.   jr nz,xcmpnz;+_
  49.   ld a,(xOP2+7)
  50.   or a
  51.   ret
  52. xcmpnz;_:
  53.   xor a
  54.   sla d
  55.   rra
  56.   rr d
  57.   sbc hl,de
  58.   ;want HL>=62
  59.   inc h
  60.   dec h
  61.   jr nz,xcmpexpok;+_
  62.   ld h,a
  63.   ld a,l
  64.   cp 62
  65.   ld a,h
  66.   jr c,xcmpexpok;+_
  67.   xor a
  68.   ret
  69. xcmpexpok;_:
  70.   or 1
  71.   rla
  72.   ret
  73.  endif
  74.