?? interpreter.bas
字號:
lByte2 = lLong1
CF_TransferBuffer(TransferBuffer_Write) = lByte2
if TransferBuffer_Write >= 1023 then
exit for
end if
else
exit for
end if
next
end if
Case "MF"
lLong2 = TransferBuffer_Write : lLong3 = 1023
if gbCntToken = 2 then
lLong1 = GetNextTokenLong(0 , 255)
elseif gbCntToken = 3 then
lLong1 = GetNextTokenLong(0 , 255)
lLong2 = GetNextTokenLong(0 , 1023)
elseif gbCntToken = 4 then
lLong1 = GetNextTokenLong(0 , 255)
lLong2 = GetNextTokenLong(0 , 1023)
lLong3 = GetNextTokenLong(lLong2 , 1023)
else
printParameterCountError "1, 2, 3 "
exit sub
end if
If gbPCInputError = cpNo then
lByte1 = lLong1
incr lLong2 : lWord2 = lLong2
Incr lLong3 : lWord3 = lLong3
for lWord1 = lWord2 to lWord3
CF_Transferbuffer(lWord1) = lByte1
next
TransferBuffer_Write = lWord1 - 1
end if
Case Else
Print #1 , "Command '" ; gsPCInput ; "' not recognized"
End Select
if Transferbuffer_write > 1023 then
Transferbuffer_write = 0
End if
End If
End Sub
Sub ExtractToken
' Counts the Token in the Input-String: gsPCInput
' following variable and arrays are filled
' cntToken: Cont of Token
' PosStrParts: positions, where the tokens start
' LenStrParts: Count of bytes of each token
Local Lstrlen As Byte
Local LparseEnd As Byte
Local Lpos1 As Byte , Lpos2 As Byte
' Init arrays with 0
For Gbcnttoken = 1 To cpToken_max
Gbposstrparts(gbcnttoken) = 0 : Gblenstrparts(gbcnttoken) = 0
Next
Gbcnttoken = 0
gsPCInput = Trim(gsPCInput)
Lstrlen = Len(gsPCInput) ' how long is string
If Lstrlen = 0 Then 'no Input ?
Exit Sub
End If
LparseEnd = 0
Lpos1 = 0
For Gbcnttoken = 1 To cpToken_max
Incr Lpos1
Lpos2 = Instr(lpos1 , gsPCInput , cpStrSep) ' find next blank
If Lpos2 = 0 Then ' no more found?
Lpos2 = Lstrlen : Incr Lpos2 : LparseEnd = 1
End If
Gblenstrparts(gbcnttoken) = Lpos2 - Lpos1 ' Lenght of token
Gbposstrparts(gbcnttoken) = Lpos1
If LparseEnd = 1 Then
Exit For
End If
Lpos1 = Lpos2
Next
End Sub
Function GetNextTokenStr(ByVal pbLen_Max as Byte ) as String
' Returns next String-token from Input
' Parameter: pbLen_Max: Limit for string-length
Local lbPos as Byte
Local lbLen as Byte
incr gbToken_actual ' switch to new/next token
lbPos = gbPosStrParts(gbToken_actual) ' at which position in string
lbLen = gbLenStrParts(gbToken_actual) ' how long
If lbLen > pbLen_Max Then lbLen = pbLen_Max ' to long?
GetNextTokenStr = mid(gsPCInput , lbPos , lbLen) ' return string
End Function
Function GetNextTokenLong(byVAl plMin as Long , byVal plMax as Long ) as Long
' returns a Long-Value from next Token and check for inside lower and upper limit
' plMin: minimum limit for return-value
' plMax: maximum limit for return-value
Local lbPos as Byte
Local lbLen as Byte
Local lsToken as String * 12
incr gbToken_actual ' switch to new/next token
lbPos = gbPosStrParts(gbToken_actual) ' at which position in string
lbLen = gbLenStrParts(gbToken_actual) ' how long
If lbLen > 12 Then lbLen = 12 ' to long?
if mid(gsPCInput , lbPos , 1) = "$" then ' Is input a HEX vlue?
incr lbPos : decr lbLen ' adjust pointer to jump over $
lsToken = mid(gsPCInput , lbPos , lbLen)
GetNextTokenLong = hexval(lstoken)
Else
lsToken = mid(gsPCInput , lbPos , lbLen)
GetNextTokenLong = val(lsToken)
End if
Select Case GetNextTokenLong ' check for limits
Case plMin to plMax ' within limits, noting to do
Case Else
gbPCInputError = cpYes ' Set Error Sign
Print #1 , Spc(lbPos) ; "^ " ; "Parameter Error ";
PrintParameterErrorL plMin , plMax ' with wanted limits
End Select
End Function
Sub PrintParameterCountError(byVAl psParm_Anzahl as String * 10)
' User message for wrong count of parameter
Print #1 , "? " ; psParm_Anzahl ; " " ; "Parameter " ; "expected "
End Sub
Sub PrintParameterErrorl(plParamLow as Long , plParamHigh as Long)
' Print Limits at wrong Input - value
Print #1 , " [ " ; plParamLow ; " ] - [ " ; plParamHigh ; " ] " ; "expected "
End Sub
Sub PrintPrompt()
Print #1 ,
Print #1 , hex(TransferBuffer_Write) ; ">" ;
End Sub
Function GetLongFromBuffer(pbSRAMArray as Byte , byVal pbPos as Word) as Long
' Extract a Long-Value from a Byte-Array
' pbSRAMArray: Byte-array, from which the Long-value should be extracted
' pbPos: Position, at which the Long-Value starts (0-based)
loadadr pbSRAMArray , Z
loadadr pbPos , X
ld r24, x+
ld r25, x+
add zl, r24
adc zh, r25
loadadr GetLongFromBuffer , X
ldi r24, 4
!Call _Mem_Copy
End Function
Function GetWordFromBuffer(pbSRAMArray as Byte , byVal pbPos as Word) as Word
' Extract a Word-value from a Byte-Array
' pbSRAMArray: Byte-array, from which the Word-value should be extracted
' pbPos: Position, at which the Word-Value starts (0-based)
loadadr pbSRAMArray , Z
loadadr pbPos , X
ld r24, x+
ld r25, x+
add zl, r24
adc zh, r25
loadadr GetWordFromBuffer , X
ldi r24, 2
!Call _Mem_Copy
End Function
Sub SRAMDump(pwSRAMPointer as Word , byVal pwLength as Word)
' Dump a Part of SRAM to Print-Output #1
' pwSRAMPointer: (Word) Variable which holds the address of SRAM to dump
' pwLength: (Word) Count of Bytes to be dumped (1-based)
Local lsDump as String * 16
Local lByte1 as Byte , lByte2 as Byte
Local lWord1 as Word , lWord2 as Word
if pwLength > 0 then
Decr pwLength
for lword1 = 0 to pwLength
lWord2 = lWord1 mod 16
if lWord2 = 0 then
if lWord1 > 0 then
Print #1 , " " ; lsDump
end if
Print #1 , hex(lWord1) ; " " ;
lsDump = " "
lByte2 = 1
end if
lByte1 = Inp(pwSRAMPointer)
incr pwSRAMPointer
Print #1 , hex(lByte1) ; " " ;
if lByte1 > 31 then
mid(lsdump , lByte2 , 1) = lByte1
else
mid(lsdump , lByte2 , 1) = "."
end if
incr lByte2
next
Print #1 , " " ; lsDump
End if
End Sub
' -----------------------------------------------------------------------------
' copy Memory from (Z) nach (X)
' counts of bytes in r24
_Mem_Copy:
ld r25, z+
st x+, r25
dec r24
brne _Mem_Copy
ret
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -