TS2068 ROM Disassembly

See all articles from SINCUS v6 n1
0F46 010300    L0F46 LD   BC,#0003
0F49 11705C LD DE,OSPCC
0F4C 21445C LD HL,NSPPC
0F4F CB7E BIT 7,(HL)
0F51 2801 JR Z,L0F54

0F53 09 ADD HL,BC

0F54 EDB8 L0F54 LDDR

0F56 FD360AFF L0F56 LD (IY+10),#FF
0F5A FDCB019E RES 3,(IY+1) ;FLAGS - K mode
0F5E FDCB029E RES 3,(IY+2) ;TV_FLAG
0F62 C3320E JP #0E32 ;Go get another line

;Error messages
; Similar to Spectrum at 1391

0F65 80 DEFB #80
0F66 4FCB DEFB "O","K"+#80

0F67 4E455854 DEFB "NEXT without FO","R"+#80
0F6C 20776974
0F70 686F7574
0F74 20464FD2
0F78 56617269 DEFB "Variable not foun","d"+#80
0F7C 61626C65
0F80 206E6F74
0F84 20666F75
0F88 6EE4
0F8A 53756273 DEFB "Subscript wron","g"+#80
0F8E 63726970
0F92 74207772
0F96 6F6EE7
0F99 4F757420 DEFB "Out of memor","y"+#80
0F9D 6F66206D
0FA1 656D6F72
0FA5 F9
0FA6 4F757420 DEFB "Out of scree","n"+#80
0FAA 6F662073
0FAE 63726565
0FB2 EE
0FB3 4E756D62 DEFB "Number too bi","g"+#80
0FB7 65722074
0FBB 6F6F2062
0FBF 69E7
0FC1 52455455 DEFB "RETURN without GOSU","B"+#80
0FC5 524E2077
0FC9 6974686F
0FCD 75742047
0FD1 4F5355C2
0FD5 456E6420 DEFB "End of fil","e"+#80
0FD9 6F662066
0FDD 696CE5
0FE0 53544F50 DEFB "STOP statemen","t"+#80
0FE4 20737461
0FE8 74656D65
0FEC 6EF4
0FEE 496E7661 DEFB "Invalid argumen","t"+#80
0FF2 6C696420
0FF6 61726775
0FFA 6D656EF4
0FFE 496E7465 DEFB "Integer out of rang","e"+#80
1002 67657220
1006 6F757420
100A 6F662072
100E 616E67E5
1012 4E6F6E73 DEFB "Nonsense in BASI","C"+#80
1016 656E7365
101A 20696E20
101E 42415349
1022 C3
1023 42524541 DEFB "BREAK - CONT repeat","s"+#80
1027 4B202D20
102B 434F4E54
102F 20726570
1033 656174F3
1037 4F757420 DEFB "Out of dat","a"+#80
103B 6F662044
103F 4154C1
1042 496E7661 DEFB "Invalid file nam","e"+#80
1046 6C696420
104A 66696C65
104E 206E616D
1052 E5
1053 4E6F2072 DEFB "No room for lin","e"+#80
1057 6F6F6D20
105B 666F7220
105F 6C696EE5
1063 53544F50 DEFB "STOP in INPU","T"+#80
1067 20696E20
106B 494E5055
106F D4
1070 464F5220 DEFB "FOR without NEX","T"+#80
1074 77697468
1078 6F757420
107C 4E4558D4
1080 496E7661 DEFB "Invalid I/O devic","e"+#80
1084 6C696420
1088 492F4F20
108C 64657669
1090 63E5
1092 496E7661 DEFB "Invalid colo","r"+#80
1096 6C696420
109A 636F6C6F
109E F2
109F 42524541 DEFB "BREAK into progra","m"+#80
10A3 4B20696E
10A7 746F2070
10AB 726F6772
10AF 61ED
10B1 52414D54 DEFB "RAMTOP no goo","d"+#80
10B5 4F50206E
10B9 6F20676F
10BD 6FE4
10BF 53746174 DEFB "Statement los","t"+#80
10C3 656D656E
10C7 74206C6F
10CB 73F4
10CD 496E7661 DEFB "Invalid strea","m"+#80
10D1 6C696420
10D5 73747265
10D9 61ED
10DB 464E2077 DEFB "FN without DE","F"+#80
10DF 6974686F
10E3 75742044
10E7 45C6
10E9 50617261 DEFB "Parameter erro","r"+#80
10ED 6D657465
10F1 72206572
10F5 726FF2
10F8 54617065 DEFB "Tape loading erro","r"+#80
10FC 206C6F61
1100 64696E67
1104 20657272
1108 6FF2
110A 4D697373 DEFB "Missing LRO","S"+#80
110E 696E6720
1112 4C524FD3
1116 2CA0 DEFB ","," "+#80
1118 7F203139 DEFB "c 1982 Sinclair Research Ltd"
111C 38322053
1120 696E636C
1124 61697220
1128 52657365
112C 61726368
1130 204C7464
1134 0D0D DEFB #0D,#0D
1136 7F203139 DEFB "c 1983 Timex Computer Cor","p"+#80
113A 38332054
113E 696D6578
1142 20436F6D
1146 70757465
114A 7220436F
114E 72F0


;Error B : No room for line
; Identical to Spectrum at 1555

1150 3E10 L1150 LD A,#10 ;Error number
1152 010000 LD BC,#0000
1155 C3E30E JP #0EE3 ;Will eventually print error message

;Add a line to the BASIC program
; Identical to Spectrum at 155D

1158 ED43495C LD (E_PPC),BC ;Make new line to be the current line
115C 2A5D5C LD HL,(CH_ADD)

115F EB L115F EX DE,HL
1160 215011 LD HL,#1150 ;Address of ERROR - B
1163 E5 PUSH HL ;Make it a RETurn address
1164 2A615C LD HL,(WORKSP)
1167 37 SCF
1168 ED52 SBC HL,DE ;length of line

116A E5 L116A PUSH HL

116B 60 L116B LD H,B
116C 69 LD L,C ;HL = line number
116D CDD616 CALL #16D6 ;See if a line already has the number
1170 2006 JR NZ,L1178 ;If not

1172 CD2017 CALL #1720 ;Find the line
1175 CD5017 CALL #1750 ;Wipe it out

1178 C1 L1178 POP BC
1179 79 LD A,C
117A 3D DEC A

117B B0 L117B OR B ;Length = 0, if it's only an ENTER
117C 2828 JR Z,L11A6 ;If length = 0

117E C5 L117E PUSH BC
117F 03 INC BC
1180 03 INC BC
1181 03 INC BC
1182 03 INC BC ;Add 4 bytesfor length & line #
1183 2B DEC HL ;Point to byte before line #
1184 ED5B535C LD DE,(PROG)
1188 D5 PUSH DE
1189 CDBB12 CALL #12BB ;Open space for line
118C E1 POP HL
118D 22535C LD (PROG),HL

1190 C1 L1190 POP BC
1191 C5 PUSH BC ;BC=length

1192 13 L1192 INC DE
1193 2A615C LD HL,(WORKSP)
1196 2B DEC HL
1197 2B DEC HL
1198 EDB8 LDDR ;Copy the line
119A 2A495C LD HL,(E_PPC) ;Line number
119D EB EX DE,HL
119E C1 POP BC ;Length
119F 70 LD (HL),B
11A0 2B DEC HL
11A1 71 LD (HL),C ;Enter the length of the line
11A2 2B DEC HL
11A3 73 LD (HL),E
11A4 2B DEC HL
11A5 72 LD (HL),D ;Enter line number to the line

11A6 F1 L11A6 POP AF
11A7 C3280E JP #0E28 ;Back to the main loop

;Initial Channel Data
; Same form as Spectrum at 15AF

;Channel K - For the edit line
11AA 0005 DEFW #0500 ;Screen/printer output address
11AC 0E0C DEFW #0C0E ;Keyboard input address
11AE 4B DEFB "K" ;This is channel K

;Channel S - Main screen output
11AF 0005 DEFW #0500 ;Screen/printer output address
11B1 BF11 DEFW #11BF ;Causes error message - no screen input
11B3 53 DEFB "S" ;This is channel S

;Channel R - RAM workspace
11B4 E70A DEFW #0AE7 ;Add character to Input or Edit works[illegible]
11B6 BF11 DEFW #11BF ;Causes error message - no RAM input
11B8 52 DEFB "R" ;This is channel R

;Channel P - Printer output
11B9 0005 DEFW #0500 ;Screen/printer output address
11BB BF11 DEFW #11BF ;Causes error message -no printer inp[illegible]
11BD 50 DEFB "P" ;This is channel P

11BE 80 DEFB #80 ;Marks end of channels

;Error J - Invalid I/O device

11BF CF RST 8
11C0 12 DEFB #12

;Initial Stream data.
; Identical to Spectrum at 15C6

11C1 0100 DEFW #0001 ;Stream FD gets channel K
11C3 0600 DEFW #0006 ;Stream FE gets channel S
11C5 0B00 DEFW #000B ;Stream FF gets channel R
11C7 0100 DEFW #0001 ;Stream 00 gets channel K
11C9 0100 DEFW #0001 ;Stream 01 gets channel K
11CB 0600 DEFW #0006 ;Stream 02 gets channel S
11CD 1000 DEFW #0010 ;Stream 03 gets channel P

;Preprocessor for current input routine. (Presently used only t[illegible]
; read the keyboard
; Identical to Spectrum at 15D4

11CF FDCB026E L91CF BIT 5,(IY+2) ;TVFLAG - to clear the edit line
11D3 2004 JR NZ,L91D9 ;if it's not necessary after a keypre[illegible]

11D5 FDCB02DE SET 3,(IY+2) ;TVFLAG - Echo requested

11D9 CDE111 L91D9 CALL #11E1 ;Eventually does a CALL (HL)
11DC D8 RET C

11DD 28FA JR Z,L91D9

11DF CF RST 8
11E0 07 DEFB #07 ;Error 8 - End of File

;Point to current channel input address
; Identical to Spectrum at 15E6

11E1 D9 EXX
11E2 E5 PUSH HL ;save registers
11E3 2A515C LD HL,(CURCHL) ;Address of current output address
11E6 23 INC HL
11E7 23 INC HL
11E8 1808 JR L91F2

###########;Output character to current channel (Also has additions to input[illegible]
; Similar to Spectrum at 15EF, but with considerable additions

;Enter here to first add #30 to character
11EA 1E30 LD E,#30
11EC 83 ADD A,E
;Enter here to output character as is. RST 10 uses this
11ED D9 EXX
11EE E5 PUSH HL
11EF 2A515C LD HL,(CURCHL)

11F2 08 L91F2 EX AF,AF'
11F3 3ABF5C LD A,(CURCBN)
11F6 FE02 CP #02 ;Is bank # > 01?
11F8 300B JR NC,L9205

11FA 08 EX AF,AF'
11FB 5E LD E,(HL)
11FC 23 INC HL
11FD 56 LD D,(HL)
11FE EB EX DE,HL
11FF CD6412 CALL #1264 ;A JP (HL). Effectively, a CALL (HL)
1202 E1 POP HL
1203 D9 EXX
1204 C9 RET


;Here for current channel bank = 2 or greater
1205 08 L9205 EX AF,AF' ;BUG!!! this is restored too early!!!
1206 2A515C LD HL,(CURCHL)
1209 46 LD B,(HL)
120A 0E88 LD C,#88 ;All chunks except 3 & 7
120C 3AC65C LD A,(ARSFLG) ;destroys output character, due to bug
120F CB47 BIT 0,A ;0=input, 1=output, if no bug
1211 2002 JR NZ,L9215 ;if it's an output routine

1213 23 INC HL
1214 23 INC HL ;Shift to input address

1215 3AC85C L9215 LD A,(STRMNM) ;Also destroys output character
1218 5F LD E,A
1219 1600 LD D,#00
121B D5 PUSH DE ;Stream number is an input parameter
121C 110700 LD DE,#0007
121F 19 ADD HL,DE
1220 E5 PUSH HL ;Address
1221 C5 PUSH BC ;Bank/Horiz Select
1222 010200 LD BC,#0002
1225 C5 PUSH BC ;2 bytes of output parameters
1226 010000 LD BC,#0000
1229 C5 PUSH BC ;No input params
122A CDD065 CALL #65D0 ;CALL_BANK
122D E1 POP HL
122E D9 EXX
122F C9 RET

###########;Attatch current channel to stream whose # is in A
; Similar to Spectrum at 1601

1230 87 ADD A,A
1231 C616 ADD A,#16
1233 6F LD L,A
1234 265C LD H,#5C ;HL = addr of stream displacement
1236 5E LD E,(HL)
1237 23 INC HL
1238 56 LD D,(HL) ;DE = actual displacement
1239 7A LD A,D
123A B3 OR E
123B 2002 JR NZ,L923F ;If it's legal (not zero)

;Error if displacement is 0 (stream closed)
123D CF RST 8
123E 17 DEFB #17 ;Error O - Invalid stream
;If MSB is 1, then it was a SYSCON displacement for expansion bank
123F FE80 L923F CP #80
1241 3022 JR NC,L9265 ;For expansion bank

1243 1B DEC DE ;Displacement starts with 0
1244 2A4F5C LD HL,(CHANS)
1247 19 ADD HL,DE ;Address of channel output address

;Find out which channel & jump to proper flags handler
; Similar to Spectrum at 1615

1248 22515C LD (CURCHL),HL
124B 3E00 LD A,#00
124D 32BF5C LD (CURCBN),A ;Current channel bank # gets 0, so as
; not to activate additional code in
; the output character routine
;In this case only, 00 points to home
; bank.
1250 FDCB30A6 RES 4,(IY+48) ;Not channel K
1254 23 INC HL
1255 23 INC HL
1256 23 INC HL
1257 23 INC HL ;Point to channel specifier (character)
1258 4E LD C,(HL) ;get it
1259 219312 LD HL,#1293 ;Address of lookup table
125C CD6B13 CALL #136B ;Scan the table
125F D0 RET NC ;Return if no match
1260 1600 LD D,#00
1262 5E LD E,(HL)
1263 19 ADD HL,DE ;Get address of flags adjuster
1264 E9 JP (HL) ;Adjust the flags (chan specific open)

######## ;Addition to Attatch Current Channel routine, to open a channel
; to an expansion bank. Won't work because of bugs
; Has no comparable Spectrum routine

1265 2ABC5C L9265 LD HL,(SYSCON) ;HL points to SYSCON table
1268 D680 SUB #80 ;BUG!! Supposed to restore D register,
126A 57 LD D,A ; but E has been ORed in. Makes garbage
126B 19 ADD HL,DE
126C 22515C LD (CURCHL),HL ;In this case, CURCHL points to addr of
; bank number
126F 7E LD A,(HL)
1270 32BF5C LD (CURCBN),A
1273 FDCB30A6 RES 4,(IY+48) ;FLAGS2 - Not channel K

;CURCHL is left pointing to a SYSCON 01; not a channel. The "attatch code" may
; want to insert a new channel & point CURCHL to it.
1277 23 INC HL
1278 23 INC HL
1279 23 INC HL
127A 23 INC HL
127B 23 INC HL
127C 23 INC HL ;Point to Attatch Current Channel code
; specific to this channel (SYSCON 07)
127D 3ABF5C LD A,(CURCBN) ;CURCBN - A already has this
1280 47 LD B,A ;Bank #
1281 0E88 LD C,#88 ;Don't deselect RAM resident code!
1283 56 LD D,(HL)
1284 23 INC HL
1285 5E LD E,(HL) ;DE = address
1286 62 LD H,D
1287 6B LD L,E ;Now it's in HL
1288 E5 PUSH HL ;Address
1289 C5 PUSH BC ;Bank #/Horiz select
128A 010000 LD BC,#0000
128D C5 PUSH BC ;No output params
128E C5 PUSH BC ;No input params
128F CDD065 CALL #65D0 ;CALL_BANK
1292 C9 RET

;Table of channel routine displacements for channel specific
; attatch code.
; Identical to Spectrum at 162D

1293 4B06 DEFB "K",#06 ;Channel K routine at 129A
1295 5312 DEFB "S",#12 ;Channel S routine at 12A8
1297 501B DEFB "P",#1B ;Channel P routine at 12B3
1299 00 DEFB #00 ;Marks end of table

;Adjust flags for channel K = Current Channel
; Identical to Spectrum at 1634

129A FDCB02C6 SET 0,(IY+2) ;TVFLAG - Lower screen
129E FDCB01AE RES 5,(IY+1) ;FLAGS - Ready for key
12A2 FDCB30E6 SET 4,(IY+48) ;FLAGS2 - channel K
12A6 1804 JR L92AC

;Adjust flags for channel S = Current Channel
; Identical to Spectrum at 1642

12A8 FDCB0286 RES 0,(IY+2) ;TVFLAG - Main screen
12AC FDCB018E L92AC RES 1,(IY+1) ;FLAGS - Send to screen, not printer
12B0 C38808 JP #0888 ;Use permanent colors & RETurn

;Adjust flags for channel P = Current Channel
; Identical to Spectrum at 164D

12B3 FDCB01CE SET 1,(IY+1) ;FLAGS - Send to printer, not screen
12B7 C9 RET

;Open up BC bytes at the location before HL
; Identical to Spectrum at 1652
;Enter here to open one space
12B8 010100 LD BC,#0001

;Enter here to open BC spaces
12BB E5 PUSH HL
12BC CDBB1F CALL #1FBB ;Make sure there's room
12BF E1 POP HL
12C0 CDCA12 CALL #12CA ;Open the space
12C3 2A655C LD HL,(STKEND)
12C6 EB EX DE,HL
12C7 EDB8 LDDR
12C9 C9 RET


;This routine actually modifies the system variables to reflect
; the recent space opened or closed up.
; Similar to Spectrum at 1664

12CA F5 PUSH AF
12CB E5 PUSH HL
12CC 21C45C LD HL,ARSBUF
12CF 5E LD E,(HL)
12D0 23 INC HL
12D1 56 LD D,(HL)
12D2 E3 EX (SP),HL
12D3 A7 AND A
12D4 ED52 SBC HL,DE
12D6 19 ADD HL,DE
12D7 E3 EX (SP),HL
12D8 3006 JR NC,L92E0

12DA EB EX DE,HL
12DB 09 ADD HL,BC
12DC EB EX DE,HL
12DD 72 LD (HL),D
12DE 2B DEC HL
12DF 73 LD (HL),E

12E0 214B5C L92E0 LD HL,VARS ;First of the Spectrum pointers
12E3 3E0E LD A,#0E ;How many pointers we may update

;Loop for all #0E, and change only those that need it
12E5 FE09 L92E5 CP #09 ;For NXTLIN
12E7 2804 JR Z,L92ED

12E9 FE08 CP #08 ;For DATADD
12EB 200D JR NZ,L92FA

;Here when updating NXTLIN or DATADD. We don't update them if
; there's an AROS present
12ED E5 L92ED PUSH HL
12EE 21C65C LD HL,ARSFLG ;ARSFLG
12F1 6E LD L,(HL)
12F2 CB7D BIT 7,L
12F4 E1 POP HL
12F5 2803 JR Z,L92FA ;If there's no AROS present

12F7 23 INC HL
12F8 1814 JR L930E

;Here for no AROS. This is like the Spectrum does it

12FA 5E L92FA LD E,(HL)
12FB 23 INC HL
12FC 56 LD D,(HL)
12FD E3 EX (SP),HL
12FE A7 AND A
12FF ED52 SBC HL,DE
1301 19 ADD HL,DE
1302 E3 EX (SP),HL
1303 3009 JR NC,L930E ;If we don't need to update the pointer

;Here if the pointer is affected by the opened space. Update it
1305 D5 PUSH DE
1306 EB EX DE,HL
1307 09 ADD HL,BC
1308 EB EX DE,HL
1309 72 LD (HL),D
130A 2B DEC HL
130B 73 LD (HL),E
130C 23 INC HL
130D D1 POP DE

130E 23 L930E INC HL ;Point to the next system variable
130F 3D DEC A
1310 20D3 JR NZ,L92E5 ;If we haven't scanned them all, yet

1312 EB EX DE,HL
1313 D1 POP DE
1314 F1 POP AF
1315 A7 AND A
1316 ED52 SBC HL,DE
1318 44 LD B,H
1319 4D LD C,L
131A 03 INC BC
131B 19 ADD HL,DE
131C EB EX DE,HL
131D C9 RET

;This spot is simply set to have #0000. Used in following code
; Identical to Spectrum at 168F

131E 0000 DEFW #0000 ;A fake "Basic line" numbered 0

;Gets the line number. Includes a dummy entry point to
; return a line number 0.
; Identical to Spectrum at 1961

1320 EB L9320 EX DE,HL
1321 111E13 LD DE,#131E

;This is the normal entry point. DE points to line number
1324 7E LD A,(HL)
1325 E6C0 AND #C0
1327 20F7 JR NZ,L9320

1329 56 LD D,(HL)
132A 23 INC HL
132B 5E LD E,(HL)
132C C9 RET

;Opens space below the calculator stack (& above the workspace[illegible]
; Identical to Spectrum at 169E
132D 2A635C LD HL,(STKBOT) ;Bottom of calculator stack
1330 2B DEC HL ;HL points to top of workspace
1331 CDBB12 CALL #12BB ;Open up BC spaces
1334 23 INC HL
1335 23 INC HL
1336 C1 POP BC
1337 ED43615C LD (WORKSP),BC
133B C1 POP BC
133C EB EX DE,HL
133D 23 INC HL
133E C9 RET

;Reclaim the various work areas, to their minimum lengths
; Identical to Spectrum at 16B0

133F 2A595C LD HL,(E_LINE) ;E_LINE. Point to edit buffer
1342 360D LD (HL),#0D ;ENTER character. The minimum edit in[illegible]
1344 225B5C LD (K_CUR),HL
1347 23 INC HL
1348 3680 LD (HL),#80
134A 23 INC HL
134B 22615C LD (WORKSP),HL
134E 2A615C LD HL,(WORKSP)
1351 22635C LD (STKBOT),HL
1354 2A635C LD HL,(STKBOT)
1357 22655C LD (STKEND),HL
135A E5 PUSH HL
135B 21925C LD HL,MEMBOT
135E 22685C LD (MEM),HL
1361 E1 POP HL
1362 C9 RET

;Reclaim the Edit workspace
; Identical to Spectrum at 16D4

1363 ED5B595C LD DE,(E_LINE)
1367 C34D17 JP #174D ;To reclaim the space

;Table look up routine. Used all over to scan the odd ROM tabl[illegible]
; Identical to Spectrum at 16DB

;This is a loop point -- NOT the entry point
136A 23 L936A INC HL ;Point to next entry, first byte

;Enter here, instead
136B 7E LD A,(HL) ;Get next entry (first byte)
136C A7 AND A
136D C8 RET Z ;00 marks end of table
136E B9 CP C
136F 23 INC HL ;Point to second byte
1370 20F8 JR NZ,L936A ;If C does not match the table entry

;Here if they match. HL points to second byte
1372 37 SCF
1373 C9 RET