Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Introspection/Locomotive-Basic/introspection-1.basic
Normal file
24
Task/Introspection/Locomotive-Basic/introspection-1.basic
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
org &4000 ; program start address
|
||||
|
||||
push bc
|
||||
push de
|
||||
push hl
|
||||
push af
|
||||
ld bc,&df00 ; select BASIC ROM
|
||||
out (c),c ; (ROM 0)
|
||||
|
||||
ld bc,&7f86 ; make ROM accessible at &c000
|
||||
out (c),c ; (RAM block 3)
|
||||
|
||||
ld hl,&c001 ; copy ROM version number to RAM
|
||||
ld de,&4040
|
||||
ld bc,3
|
||||
ldir
|
||||
|
||||
ld bc,&7f8e ; turn off ROM
|
||||
out (c),c
|
||||
pop af
|
||||
pop hl
|
||||
pop de
|
||||
pop bc
|
||||
ret
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
10 s=&4000:SYMBOL AFTER 256:MEMORY s-1
|
||||
20 FOR i=0 to 34:READ a:POKE s+i,a:NEXT
|
||||
30 DATA &c5,&d5,&e5,&f5,&01,&00,&df,&ed,&49,&01,&86,&7f,&ed,&49
|
||||
40 DATA &21,&01,&c0,&11,&40,&40,&01,&03,&00,&ed,&b0
|
||||
50 DATA &01,&8e,&7f,&ed,&49,&f1,&e1,&d1,&c1,&c9
|
||||
60 CALL s
|
||||
70 PRINT "BASIC ROM version is ";PEEK(&4040);".";PEEK(&4041);".";PEEK(&4042)
|
||||
80 IF PEEK(&4041)=0 THEN PRINT "Uh oh, you are still using BASIC 1.0":END
|
||||
90 PRINT "You are using BASIC 1.1 or later, program can continue"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
1 ' decide randomly whether to define the variable:
|
||||
10 IF RND>.5 THEN bloop=-100*RND
|
||||
20 ON ERROR GOTO 100
|
||||
30 a=@bloop ' try to get a pointer
|
||||
40 PRINT "Variable bloop exists and its value is",bloop
|
||||
50 PRINT "ABS of bloop is",ABS(bloop)
|
||||
90 END
|
||||
100 IF ERL=30 THEN PRINT "Variable bloop not defined":RESUME 90
|
||||
18
Task/Introspection/Locomotive-Basic/introspection-4.basic
Normal file
18
Task/Introspection/Locomotive-Basic/introspection-4.basic
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
10 ' The program should find and add those three integers (%), ignoring reals:
|
||||
20 foo%=-4:bar%=7:baz%=9:somereal=3.141
|
||||
30 varstart=&ae68 ' for CPC 664 and 6128
|
||||
40 ' varstart=&ae85 ' (use this line instead on the CPC 464)
|
||||
50 start=PEEK(varstart)+256*PEEK(varstart+1)
|
||||
60 WHILE start<HIMEM
|
||||
70 j=2:WHILE j<43 ' skip variable name
|
||||
80 IF PEEK(start+j)=0 GOTO 170
|
||||
90 IF PEEK(start+j)>127 THEN ptr=start+j+1:j=100
|
||||
100 j=j+1:WEND
|
||||
110 vartype=PEEK(ptr) ' integer=1, string=2, real=4
|
||||
120 IF vartype=1 THEN sum=sum+UNT(PEEK(ptr+1)+256*PEEK(ptr+2)):num=num+1:nvar=ptr+3
|
||||
130 IF vartype=2 THEN nvar=ptr+4
|
||||
140 IF vartype=4 THEN nvar=ptr+6
|
||||
150 start=nvar
|
||||
160 WEND
|
||||
170 PRINT "There are"num"integer variables."
|
||||
180 PRINT "Their sum is"sum
|
||||
Loading…
Add table
Add a link
Reference in a new issue