# KISS Spectrum v1.1 # by Ken Gagne Set Quote ¥ # If Exists ¥$ScriptPathDebug¥ Delete File ¥$ScriptPathDebug¥ # Set Debug File ¥$ScriptPathDebug¥ Set Var OD ¥$OnlineDisplay¥ Set OnlineDisplay ¥Spectrum SHR¥ Ext ScriptEditor 0 If Failed Ask1 ¥This script requires the ScriptEditor XCMD to be active.¥ ¥^^Ooops!¥ 0; Stop Script Ext Lister 0 If Failed Ask1 ¥This script requires the Lister XCMD to be active.¥ ¥^^Ooops!¥ 0; Stop Script Set KeyLock Off Set Var Buffy ¥^m¥ Set Var Neg ¥¥ Create ScriptEditor 1 Ext ScriptEditor 5 1 ¥dehqrtz¥ 1 # TopInput commands Ext ScriptEditor 5 2 ¥10112021303140414243¥ # Operands Gosubnext Zero Display ¥^L¥ Display ¥Welcome to KISS Spectrum.^m¥ Display ¥Use 'h' for help.^m¥ # TopInput Pop All Set Var TopCommand ¥¥ Display ¥-¥ Get Key TopCommand Display ¥^m¥ Ext ScriptEditor 1 1 ¥$TopCommand¥ 1 1 Pos If Not Failed On $Pos GosubNext Display, Edit, Help, Quit, Accum, Trace, Zero Else If Equal ¥$TopCommand¥ ¥^m¥ Goto TopInput Else Display ¥^mERROR: INVALID INPUT!^m^m¥; Goto TopInput Goto TopInput # Display For 0 0 9 Display ¥Cell ¥ Display ¥$ForValue00: ¥ For 1 1 10 Evaluate ¥$ForValue0*10+$ForValue1¥ CurrentCellPos Ext Lister 4 1 I $CurrentCellPos CurrentCellVal Display ¥$CurrentCellVal ¥ Next 1 Display ¥^m¥ Next 0 Display ¥Accumulator is now: $Neg$Accumulator^m¥ Return # Help Display ¥Simpletron Command Interpreter Help.^m¥ Display ¥^m¥ Display ¥The Simpletron Command Interpreter (SCI) has an interface much like the^m¥ Display ¥DOS 'debug' command. One letter commands are typed at the '-' prompt,^m¥ Display ¥with arguments as desired.^m¥ Display ¥Commands are:^m¥ Display ¥-d Display the Simpletron Memory and Accumulator.^m¥ Display ¥-e Start editing memory^m¥ Display ¥ cellnumber (cell number 00 by default)^m¥ Display ¥-h Display this help screen^m¥ Display ¥-q Quit the SCI^m¥ Display ¥-r Display contents of the Accumulator (*R*egister)^m¥ Display ¥-t Trace execution of the program beginning^m¥ Display ¥ at cell 00^m¥ Display ¥-z Clear all registers and Accumulator (*Z*ero)^m¥ Display ¥ (the ENTER key) Repeat last command.^m¥ Return # Accum Display ¥Accumulator is now: $Accumulator.^m¥ Return # Edit Display ¥Edit: Enter to keep value, q to stop input.^m¥ Display ¥Start at what memory cell (Return = 0000): ¥ Get Line StartCell If Null ¥$StartCell¥ Set Var StartCell 0000 Evaluate ¥$StartCell¥ CharContain If Not Equal ¥$StartCell¥ ¥$CharContain¥ Set Var StartCell 0000 If Equal $LengthStartCell 2 Set Var StartCell ¥0$StartCell0¥ If Not Equal $LengthStartCell 4 Set Var StartCell 0000 Substring ¥$StartCell¥ 2 1 StartTen Substring ¥$StartCell¥ 3 1 StartOne # Evaluate ¥$StartTen*10+$StartOne¥ StartCell Concatenate $StartTen $StartOne StartCell Evaluate ¥$StartCell+1¥ ActualCell # EditMore Ext Lister 4 1 I $ActualCell CurrentCellVal If Equal $LengthStartCell 1 Display ¥Cell 0$StartCell = $CurrentCellVal: ¥ Else Display ¥Cell $StartCell = $CurrentCellVal: ¥ Get Line NewCellVal If Equal ¥$NewCellVal¥ ¥q¥ Then Return If Not Equal $LengthNewCellVal 4 Then Gosubnext BadInput; Goto EditMore Evaluate ¥$NewCellVal¥ CharContain If Not Equal ¥$NewCellVal¥ ¥$CharContain¥ Gosubnext BadInput; Goto EditMore Ext Lister 3 1 $ActualCell $NewCellVal Inc ActualCell; Inc StartCell Goto EditMore # Trace Set Var Accumulator 0 Set Var StartCell 0 # TraceMore Gosub Display Display ¥^mCell ## | Opcode | Meaning^m¥ Evaluate ¥$StartCell+1¥ ActualCell Ext Lister 4 1 I $ActualCell CurrentCellVal If Equal $LengthStartCell 1 Display ¥Cell 0$StartCell : ¥ Else Display ¥Cell $StartCell : ¥ Display ¥$CurrentCellVal : ¥ Substring ¥$CurrentCellVal¥ 1 2 OpCode Substring ¥$CurrentCellVal¥ 3 2 Operand Substring ¥$OpCode¥ 1 1 Temp1 Substring ¥$OpCode¥ 2 1 Temp2 Evaluate ¥($Temp1-1)*2+$Temp2+1¥ Buffy If Equal ¥$Temp1¥ ¥0¥ Set Var Buffy 10 On $Buffy Gosubnext ReadTrace, WriteTrace, LoadTrace, StoreTrace, AddTrace, SubtractTrace, BranchTrace, BranchnegTrace, BranchzeroTrace, HaltTrace; Clear Failed If Failed Display ¥Illegal command at cell 0.^m¥; Set Var StartCell 100 # TraceEnd If Not Equal $Buffy 1 Get Key Buffy If Equal $LengthStartCell 3 Goto TopInput If Equal ¥$Buffy¥ ¥q¥ Display ¥^m^m¥; Goto TopInput If Not Equal ¥$Buffy¥ ¥^m¥ Display ¥^m¥ Goto TraceMore # ReadTrace Display ¥READ to cell $Operand... INPUT? ¥ Get Line NewCellVal # Compare $LengthNewCellVal 4 Greater # If Equal Greater 3 Then Gosubnext BadInput; Goto ReadTrace Evaluate ¥$NewCellVal¥ CharContain If Not Equal ¥$NewCellVal¥ ¥$CharContain¥ Gosubnext BadInput; Goto ReadTrace If Not Equal $LengthNewCellVal 4 Gosubnext MakeFour Inc Operand Ext Lister 3 1 $Operand ¥$NewCellVal¥ Inc StartCell Return # WriteTrace Evaluate ¥$Operand+1¥ ActualOperand Ext Lister 4 1 I $ActualOperand CurrentCellVal Display ¥WRITE cell $Operand... OUTPUT: $CurrentCellVal ¥ Inc StartCell Return # LoadTrace Evaluate ¥$Operand+1¥ ActualOperand Ext Lister 4 1 I $ActualOperand Accumulator Set Var Neg ¥¥ Display ¥LOAD cell $Operand to ACC... $Neg$Accumulator ¥ Inc StartCell Return # StoreTrace Evaluate ¥$Operand+1¥ ActualOperand Set Var NewCellVal $Accumulator; Gosubnext MakeFour; Set Var Accumulator $NewCellVal Ext Lister 3 1 $ActualOperand $Accumulator Display ¥STORE ACC to cell $Operand... $Neg$Accumulator ¥ Inc StartCell Return # AddTrace Evaluate ¥$Operand+1¥ ActualOperand Ext Lister 4 1 I $ActualOperand CurrentCellVal If Equal ¥$Neg¥ ¥¥ Gotonext PosAddTrace Evaluate ¥$Accumulator*2¥ Buffy Evaluate ¥$CurrentCellVal+$Accumulator¥ Temp Evaluate ¥$CurrentCellVal+$Accumulator-$Accumulator*2¥ If Failed Set Var Neg ¥-¥ Else Set Var Neg ¥¥ Display ¥ADD cell $Operand to ACC... $Neg$Accumulator ¥ Inc StartCell Return # SubtractTrace Evaluate ¥$Operand+1¥ ActualOperand Ext Lister 4 1 I $ActualOperand CurrentCellVal If Equal ¥$Neg¥ ¥-¥ Add $Accumulator $CurrentCellVal Accumulator; Gotonext Neg Else Evaluate ¥$Accumulator-$CurrentCellVal¥ Accumulator If Failed Set Var Neg ¥-¥ Else Set Var Neg ¥¥ # Neg Display ¥SUBTRACT cell $Operand from ACC... $Neg$Accumulator ¥ Inc StartCell Return # BranchTrace Display ¥BRANCH to $Operand... ¥ Set Var StartCell $Operand Return # BranchnegTrace Display ¥BRANCH to $Operand if ACC is negative... ¥ If Equal ¥$Neg¥ ¥-¥ Set Var StartCell $Operand Else Inc StartCell Return # BranchzeroTrace Display ¥BRANCH to $Operand if ACC is zero... ¥ If Equal $Accumulator 0 Set Var StartCell $Operand Else Inc StartCell Return # HaltTrace Display ¥HALT ¥ Get Key Buffy If Not Equal ¥$Buffy¥ ¥^m¥ Display ¥^m^m¥ Else Display ¥^m¥ Goto TopInput # BadInput Clear For 0 Display ¥^mERROR: INVALID INPUT!^m^m¥; Return # MakeFour Concatenate ¥0¥ ¥$NewCellVal¥ NewCellVal If Not Equal $LengthNewCellVal 4 Goto MakeFour Return # Zero Ext Lister 2 1 Ext Lister 1 1 100 4 100 For 0 1 100 Ext Lister 3 1 $ForValue0 0000 Next 0 Set Var Accumulator ¥0¥ Return # Quit Pop All Ext Lister 2 1 Display ¥^mGoodbye.^m¥ Stop Script