home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1986 January / 1986-01.d64 / disassembler (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  7KB  |  231 lines

  1. 100 ba=53280:pr=65490:co=646:ac=780:print"[147]":pokeba,0:pokeba+1,0
  2. 110 fora=828to985:readb:pokea,b:next
  3. 120 data 32,253,174,32,158,173,32,130,183,168,169,0,145,34,162,0,181,0,157
  4. 130 data 0,160,202,208,248,165,34,133,122,165,35,133,123,32,172,3,169,1,133
  5. 140 data 129,208,7,32,121,0,201,0,240,43,32,115,0,176,32,32,172,3,169
  6. 150 data 36,32,210,255,32,131,174,32,155,188,165,100,240,3,32,181,3,165,101
  7. 160 data 32,181,3,32,172,3,76,101,3,32,210,255,76,101,3,120,162,0,169
  8. 170 data 54,133,1,189,0,160,149,0,202,208,248,169,55,133,1,88,96,166,122
  9. 180 data 208,2,198,123,198,122,96,72,74,74,74,74,32,195,3,104,41,15,76
  10. 190 data 195,3,170,189,202,3,76,210,255,48,49,50,51,52,53,54,55,56,57
  11. 200 data 65,66,67,68,69,70
  12. 210 open15,8,15:print#15,"m-w";chr$(106)chr$(0)chr$(1)chr$(133):close15
  13. 220 open1,0
  14. 230 pokeac,147:syspr:dim c$(255),c(255)
  15. 240 pokeco,1:print"          disk disassembler"
  16. 250 reada$,b,c:ifa$="end"then290
  17. 260 c$(b)=a$:c(b)=c
  18. 270 goto250
  19. 280 poke152,0:open1,0:print"[147]"tab(4)"      disk disassembler":q$="":nu$=""
  20. 290 print:print:print"enter disassembly: r[146]am or d[146]isk"
  21. 300 getmd$:ifmd$="d"ormd$="r"then320
  22. 310 goto300
  23. 320 ifmd$="r"then340
  24. 330 goto390
  25. 340 print:print"enter starting address: ";
  26. 350 input#1,sa
  27. 360 print:print"enter ending address"
  28. 370 print"(if not known put 0): ";
  29. 380 input#1,ed:print:goto420
  30. 390 print:print"enter ml file name: ";
  31. 400 input#1,f$:open2,8,2,"0:"+f$:close2:open15,8,15:input#15,a$,b$,c$,d$
  32. 410 ifval(a$)>0then860
  33. 420 print:print"do you want list hold [y/n]: ";
  34. 430 getsp$:ifsp$="y"orsp$="n"then450
  35. 440 goto430
  36. 450 printsp$:ifsp$="y"thenlh=1
  37. 460 ifsp$="n"thenlh=0
  38. 470 close15:poke198,0
  39. 480 print"send to screen [y/n]: ";
  40. 490 getsp$:ifsp$="y"orsp$="n"then510
  41. 500 goto490
  42. 510 poke198,0
  43. 520 printsp$:ifsp$="y"thensc=1
  44. 530 ifsp$="n"thensc=0
  45. 540 print"send to printer [y/n]: ";
  46. 550 getsp$:ifsp$="y"orsp$="n"then570
  47. 560 goto550
  48. 570 poke198,0
  49. 580 printsp$:ifsp$="y"thenpr=1
  50. 590 ifsp$="n"thenpr=0
  51. 600 print"send to disk [y/n]: ";
  52. 610 poke198,0
  53. 620 getsp$:ifsp$="y"orsp$="n"then640
  54. 630 goto620
  55. 640 printsp$:ifsp$="y"thendi=1
  56. 650 ifdi=1andlh=1thenprint"list hold disactivated[146]":lh=0:er=1:gosub860
  57. 660 ifsp$="n"thendi=0
  58. 670 ifdi=0then700
  59. 680 print"enter destination's file name: ";
  60. 690 input#1,d$:print:poke198,0
  61. 700 hf=0:print"hexadecimal output [y/n]: ";:poke198,0
  62. 710 getsp$:ifsp$<>"y"andsp$<>"n"then710
  63. 720 printsp$:ifsp$="y"thenhf=1
  64. 730 print"information correct [y/n]: ";
  65. 740 getyn$:ifyn$="y"oryn$="n"then760
  66. 750 goto740
  67. 760 printyn$:ifyn$="n"then280
  68. 770 print"[147]addr.  command       op code ":close1
  69. 780 print"[163][163][163][163][163]  [163][163][163][163][163][163][163]       [163][163][163][163][163][163][163] "
  70. 790 ifmd$="d"thenopen15,8,15:print#15,"i0"
  71. 800 ifmd$="d"thenopen2,8,0,f$:close1
  72. 810 ifst<>0then860
  73. 820 ifdi=1thengosub1770:rem goto init file
  74. 830 ifpr=1thenopen4,4
  75. 840 ifst<>0then860
  76. 850 goto990
  77. 860 rem check for error
  78. 870 cc=0:ifval(a$)>0thener=0
  79. 880 ifer<>1thenprint"io/error:[146] ";a$;",";b$;",";c$;",";d$
  80. 890 ifer<>1thenclose1:close2:close3:close15
  81. 900 poke54276,0:s=54272:v=s+24:pokev,4
  82. 910 pokes+5,0*16+0:pokes+6,15*16+0:pokes+4,33
  83. 920 pokes,4:pokes+1,48:fora=0to350:next:pokes,2:pokes+1,24:fora=0to350:next
  84. 930 cc=cc+1:ifcc<>3then920
  85. 940 pokev,0:ifer=1thenreturn
  86. 950 print:print"press any key[146] to restart"
  87. 960 ifpeek(197)<>64then280
  88. 970 goto960
  89. 980 rem start disassembler
  90. 990 ifmd$="d"thenget#2,lo$:rem get starting address
  91. 1000 ifmd$="d"thenget#2,hi$:lo=asc(lo$+chr$(0)):hi=asc(hi$+chr$(0))
  92. 1010 ifmd$="d"thensa=hi*256+lo:rem starting address
  93. 1020 ifdi=1andqq=0thengosub1770
  94. 1030 ifpeek(653)then1030
  95. 1040 sx=sx+1:ifsx=19andlh=1thengosub2040
  96. 1050 ifhfandscandq$<>""thensys828,q$:printtab(20);:sys828,nu$:print:goto1070
  97. 1060 ifsc=1thenprintq$,nu$
  98. 1070 ifpr=1thenprint#4,q$+chr$(16)+"20"+nu$
  99. 1080 ifdi=1thengosub1840
  100. 1090 q$="":nu$=""
  101. 1100 gosub2000:rem get the command
  102. 1110 nu$=nu$+str$(cd)
  103. 1120 ifst<>0anddi=1thengosub1970:close1:close2:close4:close15:end
  104. 1130 ifst<>0thenclose1:close2:close4:close15:end
  105. 1140 ifsa>ed+1anded<>0thenaa=1
  106. 1150 ifaa=1anddi=0thenclose4:end
  107. 1160 ifdi=1andaa=1thengosub1970:close1:close2:close4:close15:end
  108. 1170 c$=c$(cd):c=c(cd)
  109. 1180 q$=q$+right$("0000"+mid$(str$(sa-1),2),5)+" "+left$(c$,3)
  110. 1190 ifc(cd)=1thenq$=q$+"   ":goto1030:rem 1 byte
  111. 1200 ifc(cd)=2then1250:rem 2 byte
  112. 1210 ifc(cd)=3then1420:rem 3 byte
  113. 1220 ifc(cd)=4then1710:rem conditions
  114. 1230 q$=q$+".byte "
  115. 1240 q$=q$+str$(cd):goto1030
  116. 1250 rem 2 byte command
  117. 1260 d$=mid$(c$,4,1):gosub2000
  118. 1270 nu$=nu$+str$(cd)
  119. 1280 s$=str$(cd):z$=right$(s$,len(s$)-1)
  120. 1290 ifd$="0"then1340
  121. 1300 ifd$="#"then1350
  122. 1310 ifd$="i"then1360
  123. 1320 ifd$="a"then1410
  124. 1330 goto1230:rem bad command
  125. 1340 q$=q$+str$(cd):goto1370
  126. 1350 q$=q$+" #"+z$:goto1030
  127. 1360 q$=q$+" ("+z$+")"
  128. 1370 d$=mid$(c$,5,1)
  129. 1380 ifd$="y"thenq$=q$+",y":goto1030
  130. 1390 ifd$="x"thenq$=q$+",x":goto1030
  131. 1400 goto1030
  132. 1410 q$=q$+z$:goto1030
  133. 1420 rem 3 byte command
  134. 1430 d$=mid$(c$,4,1)
  135. 1440 gosub2000:lo=cd:nu$=nu$+str$(lo)
  136. 1450 gosub2000:hi=cd:nu$=nu$+str$(hi)
  137. 1460 cd=hi*256+lo
  138. 1470 cd$=right$(str$(cd),len(str$(cd))-1)
  139. 1480 ifd$="0"then1540
  140. 1490 ifd$="#"then1550
  141. 1500 ifd$="i"then1560
  142. 1510 ifd$="a"then1630
  143. 1520 ifd$=""then1690
  144. 1530 goto1230:rem bad command
  145. 1540 q$=q$+" "+cd$:goto1030
  146. 1550 q$=q$+" #"+cd$:goto1030
  147. 1560 q$=q$+" ("+cd$+")"
  148. 1570 d$=mid$(c$,5,1)
  149. 1580 ifd$=""then1030
  150. 1590 ifd$="y"thenq$=q$+",y":goto1030
  151. 1600 ifd$="x"thenq$=q$+",x":goto1030
  152. 1610 ifd$="n"then1030
  153. 1620 goto1230:rem bad command
  154. 1630 d$=mid$(c$,5,1)
  155. 1640 ifd$=""thenq$=q$+" "+cd$:goto1030
  156. 1650 q$=q$+" "+cd$
  157. 1660 ifd$="x"thenq$=q$+",x"
  158. 1670 ifd$="y"thenq$=q$+",y"
  159. 1680 goto1030
  160. 1690 q$=q$+" "+cd$:goto1030
  161. 1700 goto1230:rem bad command
  162. 1710 rem handle condition commands
  163. 1720 gosub2000
  164. 1730 tt=0:nu$=nu$+str$(cd)
  165. 1740 ifcd>=129thentt=1:cd=cd-128
  166. 1750 iftt=1thenq$=q$+str$(sa-(128-cd)):goto1030
  167. 1760 q$=q$+str$(sa+cd):goto1030
  168. 1770 rem initialize to disk file
  169. 1780 open1,8,1,"@0:"+d$+",p,w"
  170. 1790 li=2049:qq=1
  171. 1800 hi=int(li/256):lo=li-(hi*256)
  172. 1810 print#1,chr$(lo);
  173. 1820 print#1,chr$(hi);
  174. 1830 return
  175. 1840 rem goto disk
  176. 1850 ifcd=199thengosub1970:return
  177. 1860 ifval(q$)=0thenreturn
  178. 1870 hi=int(li/256):lo=li-(hi*256)
  179. 1880 print#1,chr$(lo);
  180. 1890 print#1,chr$(hi);
  181. 1900 ss=val(q$)
  182. 1910 hi=int(ss/256):lo=ss-(hi*256)
  183. 1920 print#1,chr$(lo);
  184. 1930 print#1,chr$(hi);
  185. 1940 dd$=mid$(q$,7,20)
  186. 1950 print#1,dd$;chr$(0);
  187. 1960 return
  188. 1970 rem close disk
  189. 1980 print#1,chr$(0);chr$(0);chr$(0);chr$(0)
  190. 1990 close1:return
  191. 2000 rem*get*byte*off*of*disk*or*ram
  192. 2010 ifmd$="d"thenget#2,cd$:cd=asc(cd$+chr$(0)):sa=sa+1
  193. 2020 ifmd$="r"thencd=peek(sa):sa=sa+1
  194. 2030 return
  195. 2040 sx=0:print:print"press any key[146] to continue,f1[146] to abort."
  196. 2050 geta$:ifa$=""then2050
  197. 2060 ifa$<>"[133]"then2080
  198. 2070 close2:goto280
  199. 2080 print"[147]addr.  command       op code"
  200. 2090 print"[163][163][163][163][163]  [163][163][163][163][163][163][163]       [163][163][163][163][163][163][163]":print:return
  201. 2100 dataadc#,105,2,adc00,101,2,adc0x,117,2,adcab,109,3,adcax,128,3,adcay,121,3
  202. 2110 dataadcix,97,2,adciy,113,2
  203. 2120 dataand#,41,2,and00,37,2,and0x,53,2,andab,45,3,andax,61,3,anday,57,3
  204. 2130 dataandix,33,2,andiy,49,2
  205. 2140 dataaslac,10,1,asl00,6,2,asl0x,22,2,aslab,14,3,aslax,30,3
  206. 2150 databcc,144,4,bcs,176,4,beq,240,4,bit00,36,2,bitab,44,3,bmi,48,4,bne,208,4
  207. 2160 databpl,16,4,brk,0,1,bvc,80,4,bvs,112,4,clc,24,1,cld,216,1,cli,88,1
  208. 2170 dataclv,184,1,cmp#,201,2,cmp00,197,2,cmp0x,213,2,cmpab,205,3,cmpax,221,3
  209. 2180 datacmpay,217,3,cmpix,193,2,cmpiy,209,2
  210. 2190 datacpx#,224,2,cpx00,228,2,cpxab,236,3,cpy#,192,2,cpy00,196,2,cpyab,204,3
  211. 2200 datadec00,198,2,dec0x,214,2,decab,206,3,decax,222,3,dex,202,1,dey,136,1
  212. 2210 dataeor#,73,2,eor00,69,2,eor0x,85,2,eorab,77,3,eorab,93,3,eorax,93,3
  213. 2220 dataeoray,89,3,eorix,65,2,eoriy,81,2,inc00,230,2,inc0x,246,2,incab,238,3
  214. 2230 dataincax,254,3,inx,232,1,iny,200,1,jmpab,76,3,jmpin,108,3,jsr,32,3
  215. 2240 datalda#,169,2,lda00,165,2,lda0x,181,2,ldaab,173,3,ldaax,189,3,ldaay,185,3
  216. 2250 dataldaix,161,2,ldaiy,177,2,ldx#,162,2,ldx00,166,2,ldx0y,182,2,ldxab,174,3
  217. 2260 dataldxay,190,3,ldy#,160,2,ldy00,164,2,ldy0x,180,2,ldyab,172,3,ldyax,188,3
  218. 2270 datalsrac,74,1,lsr00,70,2,lsr0x,86,2,lsrab,78,3,lsrax,94,3,nop,234,1
  219. 2280 dataora#,9,2,ora00,5,2,ora0x,21,2,oraab,