home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 2 / 002.d81 / instring.s < prev    next >
Text File  |  2022-08-26  |  1KB  |  101 lines

  1. ;word parser
  2. * = $bffe
  3. .word $c000
  4. ;
  5. ptset=44446
  6. ptr1=41
  7. ptr2=254
  8. ad1=39
  9. ad2=252
  10. int1=32
  11. lensub=38
  12. lenmain=251
  13. varpt=71
  14. ;
  15. ;*********************************
  16. ;*      sys(xx)a$b$m%            *
  17. ;*  finds where a$ occurs in b$  *
  18. ;*                               *
  19. ;*        m%=0 if not found      *
  20. ;*        m%= starting byte      *
  21. ;*            if found           *
  22. ;*                               *
  23. ;*********************************
  24. ;
  25.  jsr ptset
  26.  lda $47 : sta ptr1
  27.  lda $48 : sta ptr1+1
  28. ;
  29.  jsr ptset
  30.  lda $47 : sta ptr2
  31.  lda $48 : sta ptr2+1
  32. ;
  33.  jsr ptset
  34.  lda $47 : sta int1
  35.  lda $48 : sta int1+1
  36. ;
  37.  ldx #00 : ldy #$00 : lda #$00
  38. ylup
  39.  lda (ptr1),y : sta lensub,x
  40.  lda (ptr2),y : sta lenmain,x
  41.  inx : iny
  42.  cpy #3 : bne ylup
  43. ;
  44.  lda #$00
  45.  sta subptr
  46.  sta mainptr
  47.  lda lenmain
  48.  sbc lensub
  49.  bcc nomatch
  50.  sta difct
  51. ;
  52. findit
  53.  ldy subptr
  54.  lda (ad1),y
  55.  sta subchar
  56.  ldy mainptr
  57.  lda (ad2),y
  58.  cmp subchar
  59.  bne diffchars
  60.  inc subptr
  61.  lda lensub
  62.  cmp subptr
  63.  beq matchexit
  64.  inc mainptr
  65.  clc
  66.  bcc findit
  67. diffchars
  68.  inc mainptr
  69. backup
  70.  lda subptr
  71.  beq okzro
  72.  dec subptr
  73.  dec mainptr
  74.  clc
  75.  bcc backup
  76. okzro
  77.  dec difct
  78.  lda #$ff
  79.  cmp difct
  80.  bne findit
  81. nomatch
  82.  lda #$00
  83.  sta lensub
  84.  beq exxit
  85. matchexit
  86.  lda mainptr
  87.  sbc lensub
  88.  sta lensub
  89.  inc lensub
  90.  inc lensub
  91. exxit
  92.  ldy #$01
  93.  lda lensub
  94.  sta (int1),y
  95.  lda #$00
  96.  tay
  97.  sta (int1),y
  98.  rts
  99.  rts
  100.  dim subptr , mainptr , difct , d , d2 , subchar
  101.  
  102.  
  103.  
  104.