*************************************
*        Mult64SpeedTest for        *
*        UMult64 and SMult64        *
*       written by Dirk Busse       *
*           26. Sep. 1998           *
*************************************


   INCDIR   include:

   include  exec/execbase.i
   include  exec/memory.i
   include  dos/dos.i
   include  LVO.i


      movea.l  4.w,a6


      clr.l    d0
      lea      DosName(pc),a1
      jsr      _LVOOpenLibrary(a6)
      movea.l  d0,a5               ; DosBase to a5
      beq      Fail

      moveq.l  #39,d0
      lea      UtilityName(pc),a1
      jsr      _LVOOpenLibrary(a6)
      movea.l  d0,a4               ; UtilityBase to a4
      bne      UtilOK
      movea.l  a5,a1
      jsr      _LVOCloseLibrary(a6) ; Close dos.library
Fail  moveq    #RETURN_FAIL,d0
      rts
UtilOK
      movea.l  a4,a6
UMult64test
      move.l   #5000000,d3
      jsr      gettime
      move.l   d7,d6

.loop move.l   #499681,d0
      move.l   #388052,d1
      jsr      _LVOUMult64(a6)
      subq.l   #1,d3
      bne      .loop

      jsr      gettime
      sub.l    d6,d7
      tst.l    d7
      bmi      UMult64test
;      bpl      .skip       ;knows someone why this two lines doesn't works?
;      neg.l    d7
.skip lea.l    result1(pc),a0
      jsr      dezi_4

SMult64test1
      move.l   #5000000,d3
      jsr      gettime
      move.l   d7,d6

.loop move.l   #499681,d0
      move.l   #388052,d1
      jsr      _LVOSMult64(a6)
      subq.l   #1,d3
      bne      .loop

      jsr      gettime
      sub.l    d6,d7
      tst.l    d7
      bmi      SMult64test1
;      bpl      .skip       ;knows someone why this two lines doesn't works?
;      neg.l    d7
.skip lea.l    result2(pc),a0
      jsr      dezi_4

SMult64test2
      move.l   #5000000,d3
      jsr      gettime
      move.l   d7,d6

.loop move.l   #-499681,d0
      move.l   #388052,d1
      jsr      _LVOSMult64(a6)
      subq.l   #1,d3
      bne      .loop

      jsr      gettime
      sub.l    d6,d7
      tst.l    d7
      bmi      SMult64test2
;      bpl      .skip       ;knows someone why this two lines doesn't works?
;      neg.l    d7
.skip lea.l    result3(pc),a0
      jsr      dezi_4


      movea.l  a5,a6               ; DosBase to a6
      jsr      _LVOOutput(a6)
      move.l   d0,d5               ; Output Handle to d5
      move.l   d5,d1               ; Output Handle to d1
      move.l   #text,d2
      move.l   #text2-text,d3
      jsr      _LVOWrite(a6)

      movea.l  a4,a6               ; UtilBase to a6
UMult64test2
      move.l   #5000000,d3
      jsr      gettime
      move.l   d7,d6

.loop move.l   #499681,d0
      clr.l    d1
      jsr      _LVOUMult64(a6)
      subq.l   #1,d3
      bne      .loop

      jsr      gettime
      sub.l    d6,d7
      tst.l    d7
      bmi      UMult64test2
;      bpl      .skip       ;knows someone why this two lines doesn't works?
;      neg.l    d7
.skip lea.l    result4(pc),a0
      jsr      dezi_4

SMult64test3
      move.l   #5000000,d3
      jsr      gettime
      move.l   d7,d6

.loop move.l   #499681,d0
      clr.l    d1
      jsr      _LVOSMult64(a6)
      subq.l   #1,d3
      bne      .loop

      jsr      gettime
      sub.l    d6,d7
      tst.l    d7
      bmi      SMult64test3
;      bpl      .skip       ;knows someone why this two lines doesn't works?
;      neg.l    d7
.skip lea.l    result5(pc),a0
      jsr      dezi_4


      movea.l  a5,a6               ; DosBase to a6
      move.l   d5,d1               ; Output Handle to d1
      move.l   #text2,d2
      move.l   #textend-text2,d3
      jsr      _LVOWrite(a6)

      movea.l  4.w,a6
      movea.l  a4,a1               ; close utility.library
      jsr      _LVOCloseLibrary(a6)
      movea.l  a5,a1               ; close dos.library
      jmp      _LVOCloseLibrary(a6)

gettime
      clr.w    d7
      move.b   $bfea01,d7
      lsl.l    #4,d7
      lsl.l    #4,d7
      move.b   $bfe901,d7
      lsl.l    #4,d7
      lsl.l    #4,d7
      move.b   $bfe801,d7
      rts

dezi_4:                           ;in a0 muß die Speicheradresse stehen, in
      divu     #1000,d7           ;die die ASCII-Zahl geschrieben werden soll
      jsr      ziffer             ;in d7 muß die Zahl stehen
      divu     #100,d7
      jsr      ziffer
      divu     #10,d7
      jsr      ziffer
ziffer
      add.b    #$30,d7
      move.b   d7,(a0)+
      clr.w    d7
      swap     d7
      rts

UtilityName
      dc.b     "utility.library",0
   EVEN
DosName
      dc.b     "dos.library",0
   EVEN
text
      dc.b     "All Results are 1/50 respectively 1/60 seconds.",$0a
      dc.b     "5000000×UMult64 (positive×positive value): "
result1
      dc.b     0,0,0,0,$0a
      dc.b     "5000000×SMult64 (positive×positive value): "
result2
      dc.b     0,0,0,0,$0a
      dc.b     "5000000×SMult64 (negative×positive value): "
result3
      dc.b     0,0,0,0,$0a,0

text2
      dc.b     "5000000×UMult64 (positive value × zero):   "
result4
      dc.b     0,0,0,0,$0a
      dc.b     "5000000×SMult64 (positive value × zero):   "
result5
      dc.b     0,0,0,0,$0a,0
textend

      dc.b     "$VER: Mult64SpeedTest 1.0 (26.Sep.1998)",0

