64 MLX

Type in and save this for Compute’s 64-MLX program. Used to type in a machine program and be able to save to tape/disk. If you are not using Proofreader, ignore the first 2 characters at the start of each line.

CCGMS-Emer Main page

SS 10 rem version 1.1: lines 830,950 modified, lines 485-487 added
EK 100 poke 56,50:clr:dim in$,i,j,a,b,a$,b$,a(7),n$
DM 110 c4=48:c6=16:c7=7:z2=2:z4=254:z5=255:z6=256:z7=127
CJ 120 fa=peek(45)+z6*peek(46):bs=peek(55)+z6*peek(56):h$=”0123456789abcdef”
SB 130 r$=chr$(13):l$=”{left}”:s$=” “:d$=chr$(20):z$=chr$(0):t$=”{rght}{rght}{rght}{rght}{rght}{rght}{rght}{rght}{rght}{rght}{rght}{rght}{rght}”
CQ 140 sd=54272:for i=sd to sd+23:poke i,0:next:poke sd+24,15:poke 788,52
FC 150 print”{clr}”chr$(142)chr$(8):poke 53280,15:poke 53281,15
EJ 160 print t$” {red}{rvon} {CBM-@}{CBM-@}{CBM-@}{CBM-@}{CBM-@}{CBM-@}{CBM-@}{CBM-@} “spc(28)” {rvof}{blu} mlx ii {red}{rvon} “spc(28)” {blu}”
FR 170 print”{down}{down}{down} compute!’s machine language editor{down}{down}{down}”
JB 180 print”{blk}starting address{gry1}”;:gosub300:sa=ad:gosub1040:if f then180
GF 190 print”{blk} ending address{gry1}”;:gosub300:ea=ad:gosub1030:if f then190
KR 200 input”{down}{down}{down}{blk}clear workspace [y/n]{gry1}”;a$:if left$(a$,1)<>”y”then220
PG 210 print”{down}{down}{blu}working…”;:fori=bs to bs+ea-sa+7:poke i,0:next:print”done”
DR 220 printtab(10)”{down}{down}{blk}{rvon} mlx command menu {down}{gry1}”:print t$”{rvon}e{rvof}nter data”
BD 230 print t$”{rvon}d{rvof}isplay data”:print t$”{rvon}l{rvof}oad file”
JS 240 print t$”{rvon}s{rvof}ave file”:print t$”{rvon}q{rvof}uit{down}{down}{blk}”
JH 250 get a$:if a$=n$ then250
HK 260 a=0:for i=1 to 5:if a$=mid$(“edlsq”,i,1)then a=i:i=5
FD 270 next:on a goto420,610,690,700,280:gosub1060:goto250
EJ 280 print”{rvon} quit “:input”{down}{gry1}are you sure [y/n]”;a$:if left$(a$,1)<>”y”then220
EM 290 poke sd+24,0:end
JX 300 in$=n$:ad=0:inputin$:iflen(in$)<>4thenreturn
KF 310 b$=in$:gosub320:ad=a:b$=mid$(in$,3):gosub320:ad=ad*256+a:return
PP 320 a=0:for j=1 to 2:a$=mid$(b$,j,1):b=asc(a$)-c4+(a$>”@”)*c7:a=a*c6+b
JA 330 if b<0 or b>15 then ad=0:a=-1:j=2
GX 340 next:return
CH 350 b=int(a/c6):print mid$(h$,b+1,1);:b=a-b*c6:print mid$(h$,b+1,1);:return
RR 360 a=int(ad/z6):gosub350:a=ad-a*z6:gosub350:print”:”;
BE 370 ck=int(ad/z6):ck=ad-z4*ck+z5*(ck>z7):goto390
PX 380 ck=ck*z2+z5*(ck>z7)+a
JC 390 ck=ck+z5*(ck>z5):return
QS 400 print”{down}starting at{gry1}”;:gosub300:if in$<>n$ then gosub1030:if f then400
EX 410 return
HD 420 print”{rvon} enter data “:gosub400:if in$=n$ then220
JK 430 open3,3:print
SK 440 poke198,0:gosub360:if f then print in$:print”{up}{rght}{rght}{rght}{rght}{rght}”;
GC 450 for i=0 to 24 step 3:b$=s$:for j=1 to 2:if f then b$=mid$(in$,i+j,1)
HA 460 print”{rvon}”b$l$;:if i<24then print”{rvof}”;
HD 470 get a$:if a$=n$ then470
FK 480 if(a$>”/”anda$<“:”)or(a$>”@”anda$<“g”)then540
GS 485 a=-(a$=”m”)-2*(a$=”,”)-3*(a$=”.”)-4*(a$=”/”)-5*(a$=”j”)-6*(a$=”k”)
FX 486 a=a-7*(a$=”l”)-8*(a$=”:”)-9*(a$=”u”)-10*(a$=”i”)-11*(a$=”o”)-12*(a$=”p”)
CM 487 a=a-13*(a$=s$):if a then a$=mid$(“abcd123e456f0″,a,1):goto 540
MP 490 if a$=r$ and((i=0)and(j=1)or f)then print b$;:j=2:next:i=24:goto550
KC 500 if a$=”{home}” then print b$:j=2:next:i=24:next:f=0:goto440
MX 510 if(a$=”{rght}”)andf thenprint b$l$;:goto540
GK 520 if a$<>l$ and a$<>d$ or((i=0)and(j=1))then gosub1060:goto470
HG 530 a$=l$+s$+l$:print b$l$;:j=2-j:if j then print l$;:i=i-3
QS 540 print a$;:next j:print s$;
PM 550 next i:print:print”{up}{rght}{rght}{rght}{rght}{rght}”;:input#3,in$:if in$=n$ then close3:goto220
QC 560 for i=1 to 25 step3:b$=mid$(in$,i):gosub320:if i<25 then gosub380:a(i/3)=a
PK 570 next:if a<>ck then gosub1060:print”{blk}{rvon} error: reenter line {gry1}”:f=1:goto440
HJ 580 gosub1080:b=bs+ad-sa:for i=0 to 7:poke b+i,a(i):next
QQ 590 ad=ad+8:if ad>ea then close3:print”{down}{blu}** end of entry **{blk}{down}{down}”:goto700
GQ 600 f=0:goto440
QA 610 print”{clr}{down}{rvon} display data “:gosub400:if in$=n$ then220
RJ 620 print”{down}{blu}press: {rvon}space{rvof} to pause, {rvon}return{rvof} to break{gry1}{down}”
KS 630 gosub360:b=bs+ad-sa:fori=bto b+7:a=peek(i):gosub350:gosub380:print s$;
CC 640 next:print”{rvon}”;:a=ck:gosub350:print
KH 650 f=1:ad=ad+8:if ad>ea thenprint”{down}{blu}** end of data **”:goto220
KC 660 get a$:if a$=r$ then gosub1080:goto220
EQ 670 if a$=s$ then f=f+1:gosub1080
AD 680 onfgoto630,660,630
CM 690 print”{down}{rvon} load data “:op=1:goto710
PC 700 print”{down}{rvon} save file “:op=0
RX 710 in$=n$:input”{down}filename{gry1}”;in$:if in$=n$ then220
PR 720 f=0:print”{down}{blk}{rvon}t{rvof}ape or {rvon}d{rvof}isk: {gry1}”;
FP 730 get a$:if a$=”t”then print”t{down}”:goto880
HQ 740 if a$<>”d”then730
HH 750 print”d{down}”:open15,8,15,”i0:”:b=ea-sa:in$=”0:”+in$:if op then810
SQ 760 open 1,8,8,in$+”,p,w”:gosub860:if a then220
FJ 770 ah=int(sa/256):al=sa-(ah*256):print#1,chr$(al);chr$(ah);
PE 780 for i=0 to b:print#1,chr$(peek(bs+i));:if st then800
FC 790 next:close1:close15:goto940
GS 800 gosub1060:print”{down}{blk}error during save:{gry1}”:gosub860:goto220
MA 810 open 1,8,8,in$+”,p,r”:gosub860:if a then220
GE 820 get#1,a$,b$:ad=asc(a$+z$)+256*asc(b$+z$):if ad<>sa then f=1:goto850
RX 830 for i=0 to b:get#1,a$:poke bs+i,asc(a$+z$):if(i<>b)and st then f=2:ad=i:i=b
FA 840 next:if st<>64 then f=3
FQ 850 close1:close15:on abs(f>0)+1 goto960,970
SA 860 input#15,a,a$:if a then close1:close15:gosub1060:print”{rvon}error: “a$
GQ 870 return
EJ 880 poke183,peek(fa+2):poke187,peek(fa+3):poke188,peek(fa+4):ifop=0then920
HJ 890 sys 63466:if(peek(783)and1)then gosub1060:print”{down}{rvon} file not found “:goto690
CS 900 ad=peek(829)+256*peek(830):if ad<>sa then f=1:goto970
SC 910 a=peek(831)+256*peek(832)-1:f=f-2*(a<ea)-3*(a>ea):ad=a-ad:goto930
KM 920 a=sa:b=ea+1:gosub1010:poke780,3:sys 63338
JF 930 a=bs:b=bs+(ea-sa)+1:gosub1010:on op goto950:sys 63591
AE 940 gosub1080:print”{blu}** save completed **”:goto220
XP 950 poke147,0:sys 63562:if st>0 then970
FR 960 gosub1080:print”{blu}** load completed **”:goto220
DP 970 gosub1060:print”{blk}{rvon}error during load:{down}{gry1}”:on f gosub980,990,1000:goto220
PP 980 print”incorrect starting address (“;:gosub360:print”)”:return
GR 990 print”load ended at “;:ad=sa+ad:gosub360:print d$:return
FD 1000 print”truncated at ending address”:return
RX 1010 ah=int(a/256):al=a-(ah*256):poke193,al:poke194,ah
FF 1020 ah=int(b/256):al=b-(ah*256):poke174,al:poke175,ah:return
FX 1030 if ad<sa or ad>ea then1050
CR 1040 if (ad>511 and ad<65280) then gosub1080: f=0: return
HC 1050 gosub1060:print”{rvon} invalid address {down}{blk}”:f=1:return
AR 1060 poke sd+5,31:poke sd+6,208:poke sd,240:poke sd+1,4:poke sd+4,33
DX 1070 for s=1 to 100:next:goto1090
PF 1080 poke sd+5,8:poke sd+6,240:poke sd,0:poke sd+1,90:poke sd+4,17
AC 1090 for s=1 to 100:next:poke sd+4,0:poke sd,0:poke sd+1,0:return