home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 545a.lha / PowerVisor_v1.0 / Source.LZH / Source / SearchHist.asm < prev    next >
Encoding:
Assembly Source File  |  1991-09-02  |  1.5 KB  |  67 lines

  1.     ;Machinelanguage script, search line in history
  2.     ;a2 = pointer to PVCallTable
  3.  
  4. Search:
  5.     ;pvcall 12, pvcall 20, pvcall 36
  6.         move.l    12*4(a2),a0
  7.         jsr        (a0)                    ;Get pointer to stringgadget buffer
  8.         move.l    d0,a3
  9.         move.l    20*4(a2),a0
  10.         jsr        (a0)                    ;Get pointer to StringInfo of stringgadget
  11.         move.l    d0,a4
  12.         move.l    36*4(a2),a0
  13.         jsr        (a0)                    ;Get pointer to MainBase
  14.         move.l    d0,a5
  15.  
  16.         move.w    8(a4),d0                ;Position in stringgadget buffer
  17.         move.b    0(a3,d0.w),d7        ;Remember byte
  18.         move.b    #0,0(a3,d0.w)        ;Clear byte
  19.  
  20.         lea        166(a5),a5            ;Remember pointer to history
  21.         move.l    (a5),a6                ;Remember this line
  22.         move.l    (a6),a6                ;Go to next
  23.  
  24. 1$        lea        10(a6),a0            ;Pointer to history string
  25.         move.l    a3,a1                    ;Pointer to stringgadget
  26.         bsr.s        Compare
  27.         beq.s        2$
  28.     ;Not equal, go to next history line
  29.         move.l    (a6),a6
  30.         cmp.l        (a5),a6                ;If a5==a6 we have turned arround
  31.                                             ;(The history list is a circular list)
  32.         beq.s        3$
  33.         bra.s        1$
  34.  
  35.     ;We have found a matching line !
  36. 2$        move.l    a6,(a5)                ;New current history
  37.  
  38.     ;pvcall 4
  39.         move.l    4*4(a2),a0
  40.         jsr        (a0)                    ;Copy current history line to stringgadget
  41.     ;pvcall 5
  42.         move.l    5*4(a2),a0
  43.         jsr        (a0)                    ;Refresh stringgadget
  44.  
  45.         moveq        #1,d0                    ;Return code success
  46.         rts
  47.  
  48.     ;No match found, restore current line
  49. 3$        move.w    8(a4),d0                ;Position in stringgadget buffer
  50.         move.b    d7,0(a3,d0.w)        ;Restore byte
  51.         moveq        #0,d0                    ;Return code failure
  52.         rts
  53.  
  54.     ;***
  55.     ;Compare two strings
  56.     ;a0 = string 1
  57.     ;a1 = string 2
  58.     ;-> Z flag true if equal
  59.     ;***
  60. Compare:
  61.         cmp.b        (a0)+,(a1)+
  62.         beq.s        Compare
  63.         tst.b        -1(a1)
  64.         rts
  65.  
  66.     END
  67.