home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_23_1988_Transactor_Publishing.d64
/
algo6510.1
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2023-02-26
|
2KB
|
52 lines
1 rem----- program 1 ------------------
2 rem
100 rem -- find the right algorithm --
110 rem
120 n=56: dim op$(n),op(n)
130 for i=1 to n: read op$(i): op(i)=0: next
140 data adc,and,asl,bcc,bcs,beq,bit,bmi,bne,bpl,brk,bvc,bvs,clc,cld,cli,clv
150 data cmp,cpx,cpy,dec,dex,dey,eor,inc,inx,iny,jmp,jsr,lda,ldx,ldy,lsr,nop
160 data ora,pha,php,pla,plp,rol,ror,rti,rts,sbc,sec,sed,sei,sta,stx,sty,tax
170 data tay,tsx,txa,txs,tya
180 def fnh(x)=int(x/256)
190 def fnl(x)=x-fnh(x)*256
300 dim tr(2,25): for i=0 to 2: for j=0 to 25: read tr(i,j): next j: next i
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
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
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
340 dim k(12,2): for i=0 to 12: for j=0 to 2: read k(i,j): next j: next i
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
360 data 4,1,16, 4,16,1, 16,4,1, 16,1,4
410 for kk=0 to 12
420 k1=k(kk,0): k2=k(kk,1): k3=k(kk,2)
430 for a0=0 to 13
440 for b0=0 to 17
450 for c0=0 to 14
460 print "k1/k2/k3/a0/b0/c0="k1;k2;k3;a0;b0;c0
500 gosub 2000: rem execute algo
600 next c0
610 next b0
620 next a0
630 next kk
640 print "nothing worked!"
800 end
1999 rem ------------------------------
2000 rem execute the algo
2010 rem
2020 xx=asc("a")
2030 for i=1 to n
2040 a$=left$(op$(i),1) : a=asc(a$)-xx
2050 b$=mid$(op$(i),2,1): b=asc(b$)-xx
2060 c$=right$(op$(i),1): c=asc(c$)-xx
2100 a1=tr(0,a)+a0: a2=a1-int(a1/14)*14: if a2=0 then a2=14
2110 b1=tr(1,b)+b0: b2=b1-int(b1/18)*18: if b2=0 then b2=18
2120 c1=tr(2,c)+c0: c2=c1-int(c1/15)*15: if c2=0 then c2=15
2200 x = a2*k1 + b2*k2 + c2*k3
2210 op(i) = fnl(x)
2300 if i=1 then goto 2400
2310 for j=1 to i-1
2320 if op(i)=op(j) then return
2330 next j
2400 next i
2410 print"it works!": end