home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_23_1988_Transactor_Publishing.d64 / algo6510.1 (.txt) < prev    next >
Commodore BASIC  |  2023-02-26  |  2KB  |  52 lines

  1. 1 rem----- program 1 ------------------
  2. 2 rem
  3. 100 rem -- find the right algorithm --
  4. 110 rem
  5. 120 n=56: dim op$(n),op(n)
  6. 130 for i=1 to n: read op$(i): op(i)=0: next
  7. 140 data adc,and,asl,bcc,bcs,beq,bit,bmi,bne,bpl,brk,bvc,bvs,clc,cld,cli,clv
  8. 150 data cmp,cpx,cpy,dec,dex,dey,eor,inc,inx,iny,jmp,jsr,lda,ldx,ldy,lsr,nop
  9. 160 data ora,pha,php,pla,plp,rol,ror,rti,rts,sbc,sec,sed,sei,sta,stx,sty,tax
  10. 170 data tay,tsx,txa,txs,tya
  11. 180 def fnh(x)=int(x/256)
  12. 190 def fnl(x)=x-fnh(x)*256
  13. 300 dim tr(2,25): for i=0 to 2: for j=0 to 25: read tr(i,j): next j: next i
  14. 310 data 1,2,3,4,5,0,0,0,6,7,0,8,0,9,10,11,0,12,13,14,0,0,0,0,0,0
  15. 320 data 1,2,3,4,5,0,0,6,7,0,0,8,9,10,11,12,0,13,14,15,0,16,0,17,18,0
  16. 330 data 1,0,2,3,4,0,0,0,5,0,6,7,0,0,0,8,9,10,11,12,0,13,0,14,15,0
  17. 340 dim k(12,2): for i=0 to 12: for j=0 to 2: read k(i,j): next j: next i
  18. 350 data 1,1,1,  1,2,4,  1,4,2,  2,1,4,  2,4,1,  4,2,1,  4,1,2,  1,4,16, 1,16,4
  19. 360 data 4,1,16, 4,16,1, 16,4,1, 16,1,4
  20. 410 for kk=0 to 12
  21. 420 k1=k(kk,0): k2=k(kk,1): k3=k(kk,2)
  22. 430 for a0=0 to 13
  23. 440 for b0=0 to 17
  24. 450 for c0=0 to 14
  25. 460 print "k1/k2/k3/a0/b0/c0="k1;k2;k3;a0;b0;c0
  26. 500 gosub 2000: rem execute algo
  27. 600 next c0
  28. 610 next b0
  29. 620 next a0
  30. 630 next kk
  31. 640 print "nothing worked!"
  32. 800 end
  33. 1999 rem ------------------------------
  34. 2000 rem execute the algo
  35. 2010 rem
  36. 2020 xx=asc("a")
  37. 2030 for i=1 to n
  38. 2040 a$=left$(op$(i),1) : a=asc(a$)-xx
  39. 2050 b$=mid$(op$(i),2,1): b=asc(b$)-xx
  40. 2060 c$=right$(op$(i),1): c=asc(c$)-xx
  41. 2100 a1=tr(0,a)+a0: a2=a1-int(a1/14)*14: if a2=0 then a2=14
  42. 2110 b1=tr(1,b)+b0: b2=b1-int(b1/18)*18: if b2=0 then b2=18
  43. 2120 c1=tr(2,c)+c0: c2=c1-int(c1/15)*15: if c2=0 then c2=15
  44. 2200 x = a2*k1 + b2*k2 + c2*k3
  45. 2210 op(i) = fnl(x)
  46. 2300 if i=1 then goto 2400
  47. 2310 for j=1 to i-1
  48. 2320 if op(i)=op(j) then return
  49. 2330 next j
  50. 2400 next i
  51. 2410 print"it works!": end
  52.