Parallax Sxkey QBL99V3.BAS
'Control the SXKEY by QBASIC M J Mulders dd 04-10-2000 QBL99V3.BAS
L05: COMPORT = 2: GOSUB L76: 'modify COMPORT if necessarily
L09: PRINT "<Q>=QUIT <R>=READ <P>=PROGRAM <D>=DEBUG";
L10: IK$ = INKEY$: IF IK$ = "" THEN FOR ikn = 1 TO 100: NEXT: GOTO L10
IF IK$ = "Q" THEN STOP
IF IK$ = "R" THEN GOTO L13
IF IK$ = "D" THEN CLS : GOSUB L83: GOTO L09
IF IK$ <> "P" THEN GOTO L10 ELSE PRINT : PRINT "I will program from "; READFILE$;
INPUT " OK=ENTER or type other filename: ", A$: IF LEN(A$) > 3 THEN READFILE$ = A$
PRINT "In use: "; READFILE$; " "; : GOSUB L65: PRINT "Programming start now"
RESTORE L60: GOSUB L20: PRINT " Ready": GOTO L09
L13: RESTORE L45: flt = 0: GOSUB L15: IF flt = 0 THEN GOSUB L35: GOSUB L127
flt = 0: PRINT " Ready": GOTO L09
L15: PRINT : PRINT "Read data from SX-chip "; : READ BEVEL: i = 0
WHILE BEVEL <> &HFF: POKE OBUF + i, BEVEL: i = i + 1: READ BEVEL: WEND
L20: POKE BREEK, 0: POKE OUTIN, 0: POKE OUTIN + 1, 0: READ BEVEL: WHILE BEVEL <> &HFF
M% = BEVEL: READ RETR: MX% = RETR: : POKE SBUSY, 1: PRINT "X";
CALL ABSOLUTE(MX%, M%, ONESHOT): IF (MX% = RETR) AND (MX% = M%) THEN GOTO L25
flt = 1: IF RETR = MX% THEN PRINT " Timeout-error!! "; : GOTO L22
IF MX% AND 16 THEN PRINT "Framing-error"; ELSE PRINT "Overflow-error";
L22: MX% = MX% - 128: PRINT "BREAK-count="; PEEK(BREEK);
PRINT " Transmitted="; BEVEL: PRINT "Expected to receive="; RETR; " Received now="; M%;
M% = 256 * PEEK(ASCIN + 1) + PEEK(ASCIN): LENG = M%: PRINT " Total received="; LENG;
IF M% = 0 THEN RETURN ELSE PRINT
CLOSE : OPEN "O", #1, "KIJK_RAW.TXT": WRITE #1, M%: FOR j = 0 TO LENG - 1
M% = (-PEEK(IBUF + j)) AND 255: WRITE #1, M%: NEXT: CLOSE : GOSUB L78
PRINT " Data now in file KIJK_RAW.TXT "; : RETURN
L25: IF M% <> 9 THEN GOTO L30: 'after 9 bytes generate encryption keys
i = PEEK(IBUF + 6): POKE SXKEY, i XOR &H37
i = PEEK(IBUF + 7): POKE SXKEY + 1, i XOR &H95: POKE CRYPT, 2
L30: READ BEVEL: WEND: GOSUB L78: RETURN
L35: CLOSE : OPEN "O", #1, "READ_KEY.TXT": PRINT : PRINT "I'm filling READ_KEY.TXT ";
PRINT #1, "Device="; : j = 10 + IBUF: GOSUB L40
PRINT #1, " Fusex="; : j = 12 + IBUF: GOSUB L40
PRINT #1, " Fuse="; : j = 14 + IBUF: GOSUB L40
PRINT #1, " Content memory": j = 17 + IBUF: BLOK = 0: TEL = 0
WHILE BLOK < 16: y = 0: WHILE y < 128: GOSUB L40: j = j + 2: y = y + 1: WEND
j = j + 1: BLOK = BLOK + 1: PRINT "*"; : WEND
PRINT #1, "Ident="; : FOR i = 1 TO 16: GOSUB L40: j = j + 2: NEXT
PRINT #1, "Timer="; : j = j + 1: GOSUB L40: PRINT #1, : PRINT " Ready": RETURN
L40: PRINT #1, HEX$(PEEK(j + 1)); : M% = PEEK(j): IF M% < 16 THEN PRINT #1, "0";
PRINT #1, HEX$(M%); " "; : TEL = TEL + 1: IF TEL = 16 THEN TEL = 0: PRINT #1,
RETURN: 'the following DATA is in use for the SXBLITS-protocol
L45: DATA &H20,&H53,&H58,&H2D,&H4B,&H65,&H79,&H3,&H3,&H80,&H80,&H80
DATA &H80,&H80,&H80,&H80,&H80,&H80,&H80,&H80,&H80,&H80,&H80,&H80
DATA &H80,&H10,&H0,&H4,&HFF
DATA 7,9,1,1,1,7,1,257,1,257,1,257,1,257,1,257,1,257,1,257,1,257,1
DATA 257,1,257,1,257,1,257,1,257,1,257,1,257,1,257,1,33,1,3,1,1,&HFF
L60: DATA 7,9,2,1,2,1,1,1,6,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1
DATA 66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1
DATA 66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1
DATA 66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1
DATA 66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1
DATA 66,1,66,1,66,1,34,1,1,3,1,1,1,0,&HFF
L65: PRINT : PRINT "I prepare data in the outputbuffer for programming SX28 "
CLOSE : OPEN "I", #2, READFILE$: TEL = 0
M$ = "2053582D4B657901FF01F5020232": GOSUB L75: INPUT #2, M$
P = 19: GOSUB L70: P = 29: GOSUB L70: FOR i = 1 TO 64: M$ = "2014": GOSUB L75
INPUT #2, M$: FOR P = 1 TO 63 STEP 4: GOSUB L70: NEXT
INPUT #2, M$: FOR P = 1 TO 63 STEP 4: GOSUB L70: NEXT
PRINT "*"; : NEXT: M$ = "1014": GOSUB L75: INPUT #2, M$
FOR P = 7 TO 70 STEP 4: GOSUB L70: NEXT: M$ = "000400": GOSUB L75
PRINT "Prepared in memory:"; TEL; "bytes "; : RETURN
L70: B = ASC(MID$(M$, P, 1)) - 48: IF B > 10 THEN B = B - 7
y = ASC(MID$(M$, P + 1, 1)) - 48: IF y > 10 THEN y = y - 7
Z = ASC(MID$(M$, P + 2, 1)) - 48: IF Z > 10 THEN Z = Z - 7
A = 16 * y + Z: POKE OBUF + TEL, A: POKE OBUF + TEL + 1, B: TEL = TEL + 2: RETURN
L75: FOR P = 1 TO LEN(M$) STEP 2
y = ASC(MID$(M$, P, 1)) - 48: IF y > 10 THEN y = y - 7
Z = ASC(MID$(M$, P + 1, 1)) - 48: IF Z > 10 THEN Z = Z - 7
A = 16 * y + Z: POKE OBUF + TEL, A: TEL = TEL + 1: NEXT: RETURN
L76: 'initialise assembler-drivers
DIM ASM%(30000), TM$(26): DEF SEG = VARSEG(ASM%(0)): ONESHOT = &H100
TYPE TestRecord: Instructie AS STRING * 41: Dummy AS STRING * 1: END TYPE
DIM SrcCode AS TestRecord: SCREEN 0, 0, 0, 0: RESTORE L79: TEL = &H100
FOR i = 1 TO 12: READ M$: FOR P = 1 TO LEN(M$) STEP 2
y = ASC(MID$(M$, P, 1)) - 48: IF y > 10 THEN y = y - 7
Z = ASC(MID$(M$, P + 1, 1)) - 48: IF Z > 10 THEN Z = Z - 7
A = 16 * y + Z: POKE OBUF + TEL, A: TEL = TEL + 1: NEXT: NEXT
READFILE$ = "READ_KEY.TXT": IF COMPORT = 1 THEN CPR = &H3F8: GOTO L77
CPR = &H2F8: POKE &H14D, 2: POKE &H15C, 2: POKE &H17E, 2: POKE &H192, 2: POKE &H20B, 2
L77: OUT (CPR + 3), &H80: OUT (CPR + 0), &H2: OUT (CPR + 1), &H0
OUT (CPR + 3), &H3: OUT (CPR + 4), &H8: PRINT "Assembler-part loaded"
SXKEY = &H108: OUTIN = &H10C: BREEK = &H107: IBUF = &H26D: OBUF = &H3D05
TM3 = &H103: SBUSY = &H102: CRYPT = &H106: ASCIN = &H10A: DEBUG = 0: pollrequest = 0
L78: IF DEBUG = 1 THEN RETURN ELSE POKE TM3, 10: POKE SBUSY, 0: POKE CRYPT, 0
POKE ASCIN, 0: POKE ASCIN + 1, 0: HX% = INP(CPR + 5): HX% = INP(CPR): RETURN
L79: DATA "EB0E0032FFFF000000000000000000001E55538BEC8B760C8B0C2E890E0E018B"
DATA "760A8B0C2E803E0601027509E8F0002EC60606010183F900742A492E8B1E0C01"
DATA "2E8A87053D432E891E0C01BAF8032E803E0601007403E80601EEBAFD03EC2440"
DATA "74F8EBD1BB00002E391E0E01746E2E8B0E04012E8A260301BB0000FABAFD03EC"
DATA "241F74503C0174082E803E0201007459BAF803EC2E803E02010074092EC60602"
DATA "0100EB26902E803E0601007403E89E00532E8B1E0A012E88876D02432E891E0A"
DATA "015B432E391E0E0174112E8A2603012E8B0E04014975A5FECC75F4FB8B760A89"
DATA "1C8BE55B5D1FCA0400502410587410512E8B0E0401E2FE592EFE060701EBD5B4"
DATA "000580008B760C8904BAF803EC2E8B1E0A012E88876D02432E891E0A01EBBC50"
DATA "512EA108018AE832E08AC4B106D2E032C424808AE5D0EC02C42E8B0E0801D0E5"
DATA "80E10102CD8AE12EA308015958C32E320609018AE02EA008012AC4E8C1FFC3E8"
DATA "BDFF2E2A0609012E32060801C3424242"
'see .ASM-file for content of assembler-routines
L80: 'the following code is in use for debugging with the SXKEY
DATA &H20,&H53,&H58,&H2D,&H4B,&H65,&H79,&H0,&HFF,7,9,1,0,&HFF
L81: DATA &H20,&H53,&H58,&H2D,&H4B,&H65,&H79,&H8,&HE0,&HE4,&H3E,&H4
DATA &HFF,7,9,4,1,1,1,&HFF
L82: LOCATE 24, 1: PRINT SPACE$(77); : LOCATE 24, 1: PRINT "End DEBUGMODE ";
M% = 2: MX% = 0: M$ = "0900": GOSUB L105: DEBUG = 0: TIMER OFF: CLOSE : GOTO L78
L83: SCREEN 0, 0, 3, 3: CLS : 'prepare helpscreen and put SXKEY in DEBUG-mode
PRINT : PRINT SPACE$(20); "Commands in READ/PROGRAM mode"
PRINT "<R> = read content SX-chip and fill file: READ_KEY.TXT and DESDEBM.TXT"
PRINT "<P> = programming SX-chip (default from file: READ_KEY.TXT)"
PRINT "<Q> = stop the QBASIC-program"
PRINT "<D> = goto DEBUG-mode Nb: the disassembler use READ_KEY.TXT"
PRINT SPACE$(28); "if not present or actual, do READ first"
PRINT : PRINT SPACE$(20); "Commands in DEBUG-mode"
PRINT "<ESC> = show this helpscreen In use: COMport="; COMPORT
PRINT "<.> = alternate between 'show all RAM' and 'show only system-RAM'"
PRINT " Nb: 'all RAM' shows 2 steps, 'system-RAM' shows 6 steps"
PRINT "<,> = show disassembler-code on actual position"
PRINT "</> = show actual string in use to command SXKEY (not all find out)"
PRINT "<H> = exit DEBUG-mode"
PRINT "<M> = modify RAM-data"
PRINT "<B> = modify breakpoint-adress"
PRINT "<A> = modify program-counter"
PRINT "<W> = walk one instruction and show results"
PRINT "<P> = run until breakpoint"
PRINT "<R> = run until <S> stop-command"
PRINT "<S> = STOP running SX-chip"
PRINT "<C> = reset SX-chip": PRINT
PRINT "On top of DEBUG-screen: '--- ' or 'INT' (like INT-knob on SXKEY28L.exe)"
PRINT SPACE$(24); "'----' or 'SKIP' (like SKIP-knob on SXKEY28L.exe)"
PRINT "On bottom of DEBUG-screen: next PC-adress"
SCREEN 0, 0, 0, 0: CLOSE : OPEN "DISDEBM.TXT" FOR RANDOM AS #1 LEN = LEN(SrcCode)
FOR i = 0 TO 22: TM$(i) = "": NEXT: RESTORE L80: GOSUB L15: RESTORE L81: DEBUG = 1: GOSUB L15
ON TIMER(1) GOSUB L110: flt = 0: TIMER ON: toon = 1: aanvang = 1: PRINT : PRINT "DEBUG-MODE"
TDEB = 0: WHILE TDEB < 2: WEND: REG$ = "070401500233"
CMD$ = "071C040B000708FD1006201000FF001F00F700F700F700104000000F8008"
M% = 2: MX% = 152: M$ = "0698": GOSUB L105: GOSUB L115
L84: LOCATE 24, 1: PRINT SPACE$(77); : LOCATE 24, 1: PRINT "Possible commands on help-screen <ESC>";
L90: IF flt = 1 THEN GOTO L82
IF pollrequest = 1 THEN pollrequest = 0: GOTO L103
IK$ = INKEY$: IF IK$ = "" THEN FOR ikn = 1 TO 100: NEXT: GOTO L90
IF IK$ = "." THEN GOTO L91
IF IK$ = "," THEN GOTO L94
IF IK$ = "/" THEN GOTO L96
IF IK$ = "H" THEN GOTO L82
IF IK$ = "M" THEN GOTO L95
IF IK$ = "B" THEN GOTO L92
IF IK$ = "A" THEN GOTO L93
IF IK$ = "W" THEN MID$(CMD$, 35, 6) = "EB00F7": GOTO L100
IF IK$ = "P" THEN MID$(CMD$, 35, 6) = "E900F7": GOTO L100
IF IK$ = "R" THEN MID$(CMD$, 35, 6) = "EA00EA": M% = 30: MX% = 0: M$ = CMD$: GOSUB L105: GOTO L90
IF IK$ = "C" THEN M% = 1: MX% = 1: M$ = "04": aanvang = 1: GOTO L101
IF IK$ = "S" THEN M% = 3: MX% = 0: M$ = "070100": GOTO L101
IF ASC(IK$) = 27 THEN SCREEN 0, 0, 3, 3: WHILE INKEY$ = "": FOR ikn = 1 TO 100: NEXT: WEND: SCREEN 0, 0, 0, 0
GOTO L90
L91: toon = toon + 1: toon = toon MOD 2: MID$(CMD$, 35, 6) = "F700F7"
FOR i = 0 TO 22: TM$(i) = "": NEXT: GOTO L100
L92: LOCATE 24, 1: PRINT SPACE$(77); : LOCATE 24, 1
PRINT "Present BREAK-adress= #"; MID$(CMD$, 48, 1); MID$(CMD$, 51, 2); " Modify (#HLL) or ENTER: ";
ii$ = "": FOR i = 1 TO 4: IK$ = ""
WHILE IK$ = "": IK$ = INKEY$: FOR ikn = 1 TO 100: NEXT: WEND: ii$ = ii$ + IK$
IF ASC(IK$) = 13 THEN PRINT "Not modified"; : GOTO L84
PRINT IK$; : NEXT: IF MID$(ii$, 1, 1) <> "#" THEN GOTO L92
MID$(CMD$, 48, 1) = MID$(ii$, 2, 1): MID$(CMD$, 51, 2) = MID$(ii$, 3, 2): GOTO L84
L93: PRINT "Present PC-counter= #"; MID$(CMD$, 12, 1); MID$(CMD$, 15, 2); " Modify (#HLL) or ENTER: ";
ii$ = "": FOR i = 1 TO 4: IK$ = ""
WHILE IK$ = "": IK$ = INKEY$: FOR ikn = 1 TO 100: NEXT: WEND: ii$ = ii$ + IK$
IF ASC(IK$) = 13 THEN PRINT "Not modified"; : GOTO L84
PRINT IK$; : NEXT: IF MID$(ii$, 1, 1) <> "#" THEN GOTO L93
MID$(CMD$, 12, 1) = MID$(ii$, 2, 1): MID$(CMD$, 15, 2) = MID$(ii$, 3, 2): MID$(CMD$, 35, 6) = "F700F7": GOTO L100
L94: SCREEN 0, 0, 1, 1: Adres$ = MID$(CMD$, 12, 1) + MID$(CMD$, 15, 2)
CLS : PRINT "Disassembled code around present location"
PRINT "----------------------------------------------"
y = 0: FOR i = 1 TO 3: x = ASC(MID$(Adres$, i, 1)) - 48: IF x > 10 THEN x = x - 7
y = 16 * y + x: NEXT: FOR i = y - 9 TO y + 11: IF i < 1 OR i > 4096 THEN GOTO skp
GET #1, i, SrcCode: IF i = (y + 1) THEN COLOR 15
PRINT SrcCode.Instructie; : COLOR 7
skp: NEXT: WHILE INKEY$ <> ",": FOR ikn = 1 TO 100: NEXT: WEND: SCREEN 0, 0, 0, 0: GOTO L84
L95: PRINT "Voer in: br=nn (b=BANK[0-8] r=REG[0-F] nn=waarde[00-FF] : ";
MID$(CMD$, 35, 6) = "F700F7": CNVREG$ = "013579BDF": ii$ = "": FOR i = 1 TO 5: IK$ = ""
WHILE IK$ = "": IK$ = INKEY$: FOR ikn = 1 TO 100: NEXT: WEND: ii$ = ii$ + IK$: PRINT IK$; : NEXT
IF MID$(ii$, 3, 1) <> "=" THEN GOTO L95
MID$(REG$, 7, 1) = MID$(CNVREG$, ASC(ii$) - 47, 1)
MID$(REG$, 8, 1) = MID$(ii$, 2, 1): MID$(REG$, 11, 2) = MID$(ii$, 4, 2)
M% = 6: MX% = 0: M$ = REG$: GOSUB L105
L96: SCREEN 0, 0, 2, 2: CLS
PRINT "Debug-commandstring (CMD$) to SXKEY. Meaning of 'XX' is still unknown!!"
PRINT "----------------------------------------------------------------------------"
FOR i = 0 TO 13: PRINT MID$(CMD$, 7 + (2 * i), 2); " "; : NEXT
PRINT MID$(CMD$, 35, 6); " "; MID$(CMD$, 41, 6); " ";
FOR i = 0 TO 6: PRINT MID$(CMD$, 47 + (2 * i), 2); " "; : NEXT
PRINT " | XX | XX | XX | XX | XX | XX | XX | | XXXXXX | XX | XX | XX |"
PRINT " | | | | | | | | | | | | |"
PRINT "reg-W | | | | | | | | | | | |"
PRINT "PC-high+ | | | | | | | | | | |"
PRINT "PC-low-------+ | | | | | | | | | |"
PRINT "STATUS-------------+ | | | | | | | | |"
PRINT "FSR----------------------+ | | | | | | | |"
PRINT "reg_0E-------------------------+ | | | | | | |"
PRINT "reg_0F-------------------------------+ | | | | | |"
PRINT "command------------------------------------+---+ | | | |"
PRINT "BREAK_adr_high-------------------------------------------+ | | |"
PRINT "BREAK_adr_low--------------------------------------------------+ | |"
PRINT "reg-M----------------------------------------------------------------+ |"
PRINT "reg_0D---------------------------------------------------------------------+"
PRINT "After <071C04><commandstring> or STOP <070100>"
PRINT " wait for poll-answer=<02>, then <0698> for content"
PRINT "CMD$-command= F700F7 --> Modify ram-adress (after <070401><3bytes>)"
PRINT "CMD$-command= EB00F7 --> Do SINGLE STEP"
PRINT "CMD$-command= E900F7 --> RUN until BREAK-adress"
PRINT "CMD$-command= EA00EA --> RUN until STOP-command <070100>"
PRINT "SXBLITZ++: POLL=<05> CONTENT=<06> COMMAND=<07> DEBUG-ON=<08> DEBUG-OFF=<09>";
WHILE INKEY$ = "": FOR ikn = 1 TO 100: NEXT: WEND: SCREEN 0, 0, 0, 0: GOTO L90
L100: M% = 30: MX% = 0: M$ = CMD$
L101: GOSUB L105
L102: TDEB = 0: WHILE TDEB < 2: WEND
L103: TDEB = 0: M% = 2: MX% = 152: M$ = "0698": GOSUB L105: GOSUB L115: GOTO L84
L105: TIMER OFF: TEL = 0: GOSUB L75: POKE SBUSY, 1: POKE OUTIN, 0
POKE OUTIN + 1, 0: POKE BREEK, 0: POKE ASCIN, 0: POKE ASCIN + 1, 0
CALL ABSOLUTE(MX%, M%, ONESHOT): IF MX% <> M% THEN flt = 1: PRINT "Something wrong"
TIMER ON: RETURN
L110: 'Polling routine. Send every second a poll and check response
TIMER OFF: TDEB = TDEB + 1: POKE SBUSY, 1: POKE OUTIN, 0: POKE OUTIN + 1, 0
POKE OBUF, &H5: PM% = 1: PMX% = 1: CALL ABSOLUTE(PMX%, PM%, ONESHOT)
IF PMX% <> PM% THEN PRINT "Polling stopped": flt = 1: TDEB = 100: RETURN
IF (PEEK(IBUF + PEEK(ASCIN) + (256 * PEEK(ASCIN + 1)) - 1) = 2) AND (TDEB > 3) THEN pollrequest = 1
TIMER ON: RETURN
'make up the tables and give presentation on screen
L115: M$ = "": T0 = 0: T1 = 0: FOR x = 0 TO 151
y = PEEK(IBUF + x): IF y < 16 THEN M$ = M$ + "0"
M$ = M$ + HEX$(y) + " ": T0 = T0 + 1
IF T1 = 0 AND T0 = 8 THEN T1 = 1: T0 = 0: REDM$(0) = M$: GOSUB L120: M$ = ""
IF T0 = 16 AND T1 = 1 THEN GOSUB L117
IF T0 = 16 THEN GOSUB L119
NEXT: MID$(REDM$(1), 40, 2) = MID$(REDM$(0), 19, 2): MID$(REDM$(1), 43, 2) = MID$(REDM$(0), 22, 2)
MID$(REDM$(1), 46, 2) = MID$(REDM$(1), 1, 2): MID$(REDM$(1), 7, 2) = MID$(REDM$(0), 7, 2)
MID$(REDM$(1), 10, 2) = MID$(REDM$(0), 13, 2): MID$(REDM$(1), 13, 2) = MID$(REDM$(0), 16, 2)
RG = ASC(MID$(REDM$(1), 14, 1)) - 48: IF RG > 10 THEN RG = RG - 7
BK = ASC(MID$(REDM$(1), 13, 1)) - 48: IF BK > 10 THEN BK = BK - 7
IF (BK MOD 2) = 0 THEN BK = (BK / 2) + 2 ELSE BK = 2
MID$(REDM$(1), 1, 2) = MID$(REDM$(BK), 1 + (3 * RG), 2): RESTORE L116
FOR i = 0 TO 15: READ M$: TM$(i + 6) = TM$(i + 6) + M$ + " "
HX$ = MID$(REDM$(1), 1 + (3 * i), 2): IF i <> 3 THEN GOTO NOST
jj = ASC(MID$(HX$, 2, 1)) - 48: IF jj > 10 THEN jj = jj - 7
jj = jj OR PD: MID$(HX$, 2, 1) = HEX$(jj)
jj = ASC(MID$(HX$, 1, 1)) - 48: IF jj > 10 THEN jj = jj - 7
jj = jj OR 1: MID$(HX$, 1, 1) = HEX$(jj)
NOST: TM$(i + 6) = TM$(i + 6) + HX$: GOSUB L118: TM$(i + 6) = TM$(i + 6) + " " + HX$
IF toon = 1 THEN FOR j = 2 TO 9: TM$(i + 6) = TM$(i + 6) + " " + MID$(REDM$(j), 1 + (3 * i), 2): NEXT
TM$(i + 6) = TM$(i + 6) + " ": NEXT
TM$(22) = TM$(22) + " Next= #" + MID$(REDM$(0), 11, 1) + MID$(REDM$(0), 7, 2) + " "
IF toon = 1 THEN TM$(22) = TM$(22) + " "
CLS : FOR i = 0 TO 22: PRINT TM$(i): NEXT: RETURN
L116: DATA "IN","RT","PC","ST","FS","RA","RB","RC","08","09","0A","0B","0C","0D","0E","0F"
L117: T1 = 2: T0 = 0: GOSUB L125
IF LEN(TM$(1)) > 75 THEN FOR i = 0 TO 22: TM$(i) = RIGHT$(TM$(i), 64 - (toon * 24)): NEXT
HX$ = MID$(REDM$(0), 13, 2): y = ASC(MID$(HX$, 1, 1)) - 48: IF y > 10 THEN y = y - 7
Z = ASC(MID$(HX$, 2, 1)) - 48: IF Z > 10 THEN Z = Z - 7
HX% = 16 * y + Z
IF (HX% AND 16) <> 0 THEN TM$(0) = TM$(0) + " INT " ELSE TM$(0) = TM$(0) + " --- "
IF (HX% AND 8) <> 0 THEN TM$(0) = TM$(0) + " SKIP " ELSE TM$(0) = TM$(0) + " ---- "
HX$ = MID$(REDM$(0), 1, 2): TM$(1) = TM$(1) + "M= " + HX$ + " ": GOSUB L118: TM$(1) = TM$(1) + HX$ + " "
HX$ = MID$(REDM$(0), 4, 2): TM$(2) = TM$(2) + "W= " + HX$ + " ": GOSUB L118: TM$(2) = TM$(2) + HX$ + " "
HX$ = MID$(M$, 7, 2): TM$(3) = TM$(3) + "U1= " + HX$
HX$ = MID$(M$, 40, 2): TM$(3) = TM$(3) + " U4= " + HX$ + " "
IF toon = 1 THEN TM$(0) = TM$(0) + " ": TM$(1) = TM$(1) + " "
HX$ = MID$(M$, 10, 2): TM$(4) = TM$(4) + "U2= " + HX$
PD = ASC(MID$(HX$, 2, 1)) - 48: IF PD > 10 THEN PD = PD - 7
PD = (PD AND 8)
HX$ = MID$(M$, 43, 2): TM$(4) = TM$(4) + " U5= " + HX$ + " "
IF toon = 1 THEN TM$(2) = TM$(2) + " ": TM$(3) = TM$(3) + " "
HX$ = MID$(M$, 13, 2): TM$(5) = TM$(5) + "U3= " + HX$
HX$ = MID$(M$, 46, 2): TM$(5) = TM$(5) + " U6= " + HX$ + " "
IF toon = 1 THEN TM$(4) = TM$(4) + " ": TM$(5) = TM$(5) + " "
REDM$(1) = M$: M$ = "": RETURN
L118: y = ASC(MID$(HX$, 1, 1)) - 48: IF y > 10 THEN y = y - 7
Z = ASC(MID$(HX$, 2, 1)) - 48: IF Z > 10 THEN Z = Z - 7
HX% = 16 * y + Z: HX$ = "": FOR G = 0 TO 7
HX$ = CHR$(48 + (HX% MOD 2)) + HX$: HX% = INT(HX% / 2): NEXT
RETURN
L119: T0 = 0: T1 = T1 + 1: REDM$(T1 - 1) = M$: M$ = "": RETURN
L120: MID$(CMD$, 55, 2) = MID$(M$, 1, 2): 'MODE
MID$(CMD$, 7, 2) = MID$(M$, 4, 2): 'W-reg
MID$(CMD$, 23, 2) = MID$(M$, 16, 2): 'FSR
MID$(CMD$, 59, 2) = MID$(M$, 19, 2): 'reg-0D
MID$(CMD$, 27, 2) = MID$(M$, 22, 2): 'reg-0E
MID$(CMD$, 19, 2) = MID$(M$, 13, 2): 'STATUS
IF aanvang = 0 THEN GOTO L121 ELSE aanvang = 0
MID$(REDM$(0), 13, 1) = "0": MID$(CMD$, 19, 1) = "0"
i = ASC(MID$(CMD$, 20, 1)) - 48: IF i > 10 THEN i = i - 7
MID$(CMD$, 20, 1) = CHR$((i AND 7) + 48)
MID$(CMD$, 11, 2) = "07": MID$(CMD$, 15, 2) = "FD": RETURN: 'PC-adress
L121: MID$(CMD$, 11, 2) = MID$(M$, 10, 2): MID$(CMD$, 15, 2) = MID$(M$, 7, 2): RETURN: 'PC-adress
L125: MID$(CMD$, 31, 2) = MID$(M$, 1, 2): RETURN: 'reg-0F
'this is the internal disassembler. Result in file: DISDEBM.TXT
'the input is always READ_KEY.TXT !!!
L127: CLOSE : OPEN "read_key.txt" FOR INPUT AS #1
OPEN "disdebm.txt" FOR OUTPUT AS #2: LINE INPUT #1, A$: adr = 0
PRINT "I'm busy to create the disassembler-file. One moment please!!"
Csrc: PRINT "."; : M$ = "": LINE INPUT #1, A$: IF LEN(A$) <> 64 THEN GOTO Cstp
FOR i = 0 TO 15
c3 = ASC(MID$(A$, 1 + (4 * i), 1)) - 48: IF c3 > 10 THEN c3 = c3 - 7
c2 = ASC(MID$(A$, 2 + (4 * i), 1)) - 48: IF c2 > 10 THEN c2 = c2 - 7
c1 = ASC(MID$(A$, 3 + (4 * i), 1)) - 48: IF c1 > 10 THEN c1 = c1 - 7
M$ = M$ + "$": IF (adr + i) < 16 THEN M$ = M$ + "00": GOTO Cadr
IF (adr + i) < 256 THEN M$ = M$ + "0"
Cadr: M$ = M$ + HEX$(adr + i): M$ = M$ + " [" + HEX$(c3) + HEX$(c2) + HEX$(c1) + "] "
GOSUB Cxxx
IF LEN(M$) < 40 THEN M$ = M$ + SPACE$(40 - LEN(M$))
PRINT #2, M$: M$ = "": NEXT i: adr = adr + 16: IF adr < 2047 THEN GOTO Csrc
Cstp: CLOSE : RETURN
Cxxx: ON (c3 + 1) GOTO C0xx, C1xx, C2xx, C3xx, C4xx, C5xx, C6xx, C7xx, C8xx, C9xx, CAxx, CBxx, CCxx, CDxx, CExx, CFxx
C0xx: ON (c2 + 1) GOTO C00x, C01x, C02x, C03x, C04x, C05x, C06x, C07x, C08x, C09x, C0Ax, C0Bx, C0Cx, C0Dx, C0Ex, C0Fx
C00x: ON (c1 + 1) GOTO C000, C001, C002, C003, C004, C005, C006, C007, C008, C009, C00A, C00B, C00C, C00D, C00E, C00F
C000: M$ = M$ + "NOP ": RETURN
C001: M$ = M$ + "TRIS unknown": RETURN
C002: M$ = M$ + "OPTION ": RETURN
C003: M$ = M$ + "SLEEP ": RETURN
C004: M$ = M$ + "CLRWDT ": RETURN
C005: M$ = M$ + "TRIS prt_A": RETURN
C006: M$ = M$ + "TRIS prt_B": RETURN
C007: M$ = M$ + "TRIS prt_C": RETURN
C00C: M$ = M$ + "RET ": RETURN
C00D: M$ = M$ + "RETP ": RETURN
C00E: M$ = M$ + "RETI ": RETURN
C00F: M$ = M$ + "RETIW ": RETURN
C008:
C009:
C00A:
C00B: M$ = M$ + "unknown": RETURN
C01x: IF c1 < 8 THEN M$ = M$ + "PAGE " + HEX$(c1) + " start on $" + HEX$(2 * c1) + "00": RETURN
M$ = M$ + "BANK " + HEX$(c1 - 8): RETURN
C02x: M$ = M$ + "MOVWF ": GOSUB C200: M$ = M$ + "": RETURN
C03x: M$ = M$ + "MOVWF Reg#1" + HEX$(c1): RETURN
C06x: M$ = M$ + "CLRF ": GOSUB C200: RETURN
C07x: M$ = M$ + "CLRF Reg#1" + HEX$(c1): RETURN
C05x: M$ = M$ + "MODE #" + HEX$(c1): RETURN
C08x: M$ = M$ + "SUBWF ": GOSUB C200: M$ = M$ + ",W": RETURN
C09x: M$ = M$ + "SUBWF Reg#1" + HEX$(c1) + ",W": RETURN
C0Ax: M$ = M$ + "SUBWF ": GOSUB C200: M$ = M$ + ",f": RETURN
C0Bx: M$ = M$ + "SUBWF Reg#1" + HEX$(c1) + ",f": RETURN
C0Cx: M$ = M$ + "DECF ": GOSUB C200: M$ = M$ + ",W": RETURN
C0Dx: M$ = M$ + "DECF Reg#1" + HEX$(c1) + ",W": RETURN
C0Ex: M$ = M$ + "DECF ": GOSUB C200: M$ = M$ + ",f": RETURN
C0Fx: M$ = M$ + "DECF Reg#1" + HEX$(c1) + ",f": RETURN
C04x: ON (c1 + 1) GOTO C040, C041, C042, C043, C044, C045, C046, C047, C048, C049, C04A, C04B, C04C, C04D, C04E, C04F
M$ = M$ + "unknown": RETURN
C040: M$ = M$ + "CLRW ": RETURN
C041: M$ = M$ + "IREAD ": RETURN
C042: M$ = M$ + "MOVMW ": RETURN
C043: M$ = M$ + "CLRW ": RETURN
C044: M$ = M$ + "DEBUG-command_[044]": RETURN: 'special DEBUG-command in SX28
C045: M$ = M$ + "DEBUG-command_[045]": RETURN: 'special DEBUG-command in SX28
C046: M$ = M$ + "DEBUG-command_[046]": RETURN: 'special DEBUG-command in SX28
C047: M$ = M$ + "DEBUG-command_[047]": RETURN: 'special DEBUG-command in SX28
C048: M$ = M$ + "DEBUG-command_[048]": RETURN: 'special DEBUG-command in SX28
C049: M$ = M$ + "DEBUG-command_[049]": RETURN: 'special DEBUG-command in SX28
C04A: M$ = M$ + "DEBUG-command_[04A]": RETURN: 'special DEBUG-command in SX28
C04B: M$ = M$ + "DEBUG-command_[04B]": RETURN: 'special DEBUG-command in SX28
C04C: M$ = M$ + "DEBUG-command_[04C]": RETURN: 'special DEBUG-command in SX28
C04D: M$ = M$ + "DEBUG-command_[04D]": RETURN: 'special DEBUG-command in SX28
C04E: M$ = M$ + "DEBUG-command_[04E]": RETURN: 'special DEBUG-command in SX28
C04F: M$ = M$ + "DEBUG-command_[04F]": RETURN: 'special DEBUG-command in SX28
C1xx: ON (c2 + 1) GOTO C10x, C11x, C12x, C13x, C14x, C15x, C16x, C17x, C18x, C19x, C1Ax, C1Bx, C1Cx, C1Dx, C1Ex, C1Fx
C10x: M$ = M$ + "IORWF ": GOSUB C200: M$ = M$ + ",W": RETURN
C11x: M$ = M$ + "IORWF Reg#1" + HEX$(c1) + ",W": RETURN
C12x: M$ = M$ + "IORWF ": GOSUB C200: M$ = M$ + ",f": RETURN
C13x: M$ = M$ + "IORWF Reg#1" + HEX$(c1) + ",f": RETURN
C14x: M$ = M$ + "ANDWF ": GOSUB C200: M$ = M$ + ",W": RETURN
C15x: M$ = M$ + "ANDWF Reg#1" + HEX$(c1) + ",W": RETURN
C16x: M$ = M$ + "ANDWF ": GOSUB C200: M$ = M$ + ",f": RETURN
C17x: M$ = M$ + "ANDWF Reg#1" + HEX$(c1) + ",f": RETURN
C18x: M$ = M$ + "XORWF ": GOSUB C200: M$ = M$ + ",W": RETURN
C19x: M$ = M$ + "XORWF Reg#1" + HEX$(c1) + ",W": RETURN
C1Ax: M$ = M$ + "XORWF ": GOSUB C200: M$ = M$ + ",f": RETURN
C1Bx: M$ = M$ + "XORWF Reg#1" + HEX$(c1) + ",f": RETURN
C1Cx: M$ = M$ + "ADDWF ": GOSUB C200: M$ = M$ + ",W": RETURN
C1Dx: M$ = M$ + "ADDWF Reg#1" + HEX$(c1) + ",W": RETURN
C1Ex: M$ = M$ + "ADDWF ": GOSUB C200: M$ = M$ + ",f": RETURN
C1Fx: M$ = M$ + "ADDWF Reg#1" + HEX$(c1) + ",f": RETURN
C2xx: ON (c2 + 1) GOTO C20x, C21x, C22x, C23x, C24x, C25x, C26x, C27x, C28x, C29x, C2Ax, C2Bx, C2Cx, C2Dx, C2Ex, C2Fx
C20x: M$ = M$ + "MOVF ": GOSUB C200: M$ = M$ + ",W": RETURN
C21x: M$ = M$ + "MOVF Reg#1" + HEX$(c1) + ",W": RETURN
C22x: M$ = M$ + "MOVF ": GOSUB C200: M$ = M$ + ",f": RETURN
C23x: M$ = M$ + "COMF Reg#1" + HEX$(c1) + ",f": RETURN
C24x: M$ = M$ + "COMF ": GOSUB C200: M$ = M$ + ",W": RETURN
C25x: M$ = M$ + "COMF Reg#1" + HEX$(c1) + ",W": RETURN
C26x: M$ = M$ + "COMF ": GOSUB C200: M$ = M$ + ",f": RETURN
C27x: M$ = M$ + "COMF Reg#1" + HEX$(c1) + ",f": RETURN
C28x: M$ = M$ + "INCF ": GOSUB C200: M$ = M$ + ",W": RETURN
C29x: M$ = M$ + "INCF Reg#1" + HEX$(c1) + ",W": RETURN
C2Ax: M$ = M$ + "INCF ": GOSUB C200: M$ = M$ + ",f": RETURN
C2Bx: M$ = M$ + "INCF Reg#1" + HEX$(c1) + ",f": RETURN
C2Cx: M$ = M$ + "DECFSZ ": GOSUB C200: M$ = M$ + ",W": RETURN
C2Dx: M$ = M$ + "DECFSZ Reg#1" + HEX$(c1) + ",W": RETURN
C2Ex: M$ = M$ + "DECFSZ ": GOSUB C200: M$ = M$ + ",f": RETURN
C2Fx: M$ = M$ + "DECFSZ Reg#1" + HEX$(c1) + ",f": RETURN
C3xx: ON (c2 + 1) GOTO C30x, C31x, C32x, C33x, C34x, C35x, C36x, C37x, C38x, C39x, C3Ax, C3Bx, C3Cx, C3Dx, C3Ex, C3Fx
C30x: M$ = M$ + "RRF ": GOSUB C200: M$ = M$ + ",W": RETURN
C31x: M$ = M$ + "RRF Reg#1" + HEX$(c1) + ",W": RETURN
C32x: M$ = M$ + "RRF ": GOSUB C200: M$ = M$ + ",f": RETURN
C33x: M$ = M$ + "RRF Reg#1" + HEX$(c1) + ",f": RETURN
C34x: M$ = M$ + "RLF ": GOSUB C200: M$ = M$ + ",W": RETURN
C35x: M$ = M$ + "RLF Reg#1" + HEX$(c1) + ",W": RETURN
C36x: M$ = M$ + "RLF ": GOSUB C200: M$ = M$ + ",f": RETURN
C37x: M$ = M$ + "RLF Reg#1" + HEX$(c1) + ",f": RETURN
C38x: M$ = M$ + "SWAPF ": GOSUB C200: M$ = M$ + ",W": RETURN
C39x: M$ = M$ + "SWAPF Reg#1" + HEX$(c1) + ",W": RETURN
C3Ax: M$ = M$ + "SWAPF ": GOSUB C200: M$ = M$ + ",f": RETURN
C3Bx: M$ = M$ + "SWAPF Reg#1" + HEX$(c1) + ",f": RETURN
C3Cx: M$ = M$ + "INCFSZ ": GOSUB C200: M$ = M$ + ",W": RETURN
C3Dx: M$ = M$ + "INCFSZ Reg#1" + HEX$(c1) + ",W": RETURN
C3Ex: M$ = M$ + "INCFSZ ": GOSUB C200: M$ = M$ + ",f": RETURN
C3Fx: M$ = M$ + "INCFSZ Reg#1" + HEX$(c1) + ",f": RETURN
C4xx: M$ = M$ + "BCF ": GOSUB C150: M$ = M$ + ",bit" + HEX$(INT(c2 / 2)): RETURN
C5xx: M$ = M$ + "BSF ": GOSUB C150: M$ = M$ + ",bit" + HEX$(INT(c2 / 2)): RETURN
C6xx: M$ = M$ + "BTFSC ": GOSUB C150: M$ = M$ + ",bit" + HEX$(INT(c2 / 2)): RETURN
C7xx: M$ = M$ + "BTFSS ": GOSUB C150: M$ = M$ + ",bit" + HEX$(INT(c2 / 2)): RETURN
C8xx: M$ = M$ + "RETLW #" + HEX$(c2) + HEX$(c1): RETURN
C9xx: M$ = M$ + "CALL $" + HEX$(c2) + HEX$(c1): RETURN
CAxx: M$ = M$ + "GOTO $0" + HEX$(c2) + HEX$(c1): RETURN
CBxx: M$ = M$ + "GOTO $1" + HEX$(c2) + HEX$(c1): RETURN
CCxx: M$ = M$ + "MOVLW #" + HEX$(c2) + HEX$(c1): RETURN
CDxx: M$ = M$ + "IORLW #" + HEX$(c2) + HEX$(c1): RETURN
CExx: M$ = M$ + "ANDLW #" + HEX$(c2) + HEX$(c1): RETURN
CFxx: M$ = M$ + "XORLW #" + HEX$(c2) + HEX$(c1): RETURN
C150: IF (c2 MOD 2) = 1 THEN M$ = M$ + "Reg#" + HEX$(c2 MOD 2) + HEX$(c1): RETURN
C200: IF c1 > 7 THEN M$ = M$ + "Reg#0" + HEX$(c1): RETURN
ON (c1 + 1) GOTO REG0, REG1, REG2, REG3, REG4, REG5, REG6, REG7
REG0: M$ = M$ + "IND": RETURN
REG1: M$ = M$ + "RTCC": RETURN
REG2: M$ = M$ + "PC": RETURN
REG3: M$ = M$ + "STATUS": RETURN
REG4: M$ = M$ + "FSR": RETURN
REG5: M$ = M$ + "Port_A": RETURN
REG6: M$ = M$ + "Port_B": RETURN
REG7: M$ = M$ + "Port_C": RETURN
M$ = M$ + "unknown code.................": RETURN
file: /Techref/parallax/sxkey/qbl99v3.bas, 28KB, , updated: 2001/1/9 19:30, local time: 2024/12/26 11:06,
|
| ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://linistepper.com/techref/parallax/sxkey/qbl99v3.bas"> parallax sxkey qbl99v3</A> |
Did you find what you needed?
|