Code:
'Dump von Speicheradressen im verfügbaren Bereich (beim Atmega128 ab &H0100, abhängig vom Controller)
'Adressen müssen immer in Hex und 4-stellig eingegeben werden
'Werte genau so, wie im 'SHOW RESULT' angegeben
'm1234((B)WILS) Memory Adresse &H1234 vom angegebenen Typ(byte(default) , Word , Integer , Long , String(bis zum ersten 0-byte)
'm1234-5678 Memory Adresse von &H1234 bis &H5678 (beides 4-stellig)
'm1234,0100((B)WIL) Memory ab Adresse &H1234 &H0100 Elemente vom angegebenen Typ ausgeben (beides 4-stellig)
'c1234,89ab((B)WIL) Ab Memory Adresse &H1234 die Bytes $H89ab schreiben; wenn Typ angegeben, dann werden die LSB und MSB entsprechend gedreht und es wird nur ein Wert von diesem Typ geschrieben
'c1234,"123abc" Ab Memory Adresse &H1234 wird der String "123abc" geschreiben
$dbg
$regfile = "M128def.dat"
$crystal = 16000000
$baud = 115200
Config Serialin = Buffered , Size = 100 , Bytematch = 13
Const Mem_start = $0100 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Startwert des verfügbaren Speicherbereichs
Dim B_temp As Byte ,
Dim W_temp As Word
Dim I_temp As Integer
Dim L_temp As Long
Dim S_temp As String * 100
Dim Mem_anfang As Word
Dim Mem_ende As Word
Dim Mem_count As Word
Dim Mem_pos As Word
Dim Command_key As Byte
Dim Command_count As Byte
Dim Interrupt_flag As Byte
Dim Command_string As String * 100
Dim S_temp_ovly(10) As Byte At S_temp Overlay
Dim Mem(1) As Byte At Mem_start Overlay
Enable Interrupts
Do
If Interrupt_flag.0 = 1 Then
Print Command_string
'Ausgeben
If Left(command_string , 1) = "m" Then
S_temp = Mid(command_string , 2 , 4)
Mem_anfang = Hexval(s_temp)
Mem_count = 1
If Instr(command_string , ",") > 0 Then
B_temp = Instr(command_string , ",")
Incr B_temp
S_temp = Mid(command_string , B_temp , 4)
Mem_count = Hexval(s_temp)
End If
Mem_pos = Mem_anfang
If Mem_anfang >= Mem_start Then Mem_anfang = Mem_anfang - Mem_start
Incr Mem_anfang
If Instr(command_string , "-") > 0 Then
B_temp = Instr(command_string , "-")
Incr B_temp
S_temp = Mid(command_string , B_temp , 4)
Mem_ende = Hexval(s_temp)
If Mem_ende >= Mem_start Then Mem_ende = Mem_ende - Mem_start
Incr Mem_ende
For W_temp = Mem_anfang To Mem_ende
Reset Watchdog
Print Mem_pos ; ":" ; Hex(mem_pos) ; "=" ; Hex(mem(w_temp)) ; ":" ; Mem(w_temp) ; ":" ; Chr(mem(w_temp))
Incr Mem_pos
Next W_temp
Else
While Mem_count > 0
Reset Watchdog
If Len(command_string) = 5 Or Len(command_string) = 10 Then 'Ausgabe Format mem0100
B_temp = Mem(mem_anfang)
S_temp = Str(b_temp)
Print Mem_pos ; ":" ; Hex(mem_pos) ; "=" ; Hex(b_temp) ; ":" ; Format(s_temp , " ") ; ":" ; Chr(b_temp)
Elseif Right(command_string , 1) = "B" Or Right(command_string , 1) = "b" Then 'Ausgabe Byte-Format mem0100B und mem0100,0020B
B_temp = Mem(mem_anfang)
S_temp = Str(b_temp)
Print Mem_pos ; ":" ; Hex(mem_pos) ; "=" ; Hex(b_temp) ; ":" ; Format(s_temp , " ") ; ":" ; Chr(b_temp)
Elseif Right(command_string , 1) = "W" Or Right(command_string , 1) = "w" Then 'Ausgabe Word-Format mem0100W und mem0100,0020W
Print Mem_pos ; ":" ; Hex(mem_pos) ; "=" ;
Incr Mem_anfang ' Ausgabe von 2 byte, in umgedrehter Reihenfolge
W_temp = Mem(mem_anfang)
Shift W_temp , Left , 8
Decr Mem_anfang
W_temp = W_temp + Mem(mem_anfang)
Incr Mem_anfang
Incr Mem_pos
Print Hex(w_temp) ; ":" ; W_temp
Elseif Right(command_string , 1) = "I" Or Right(command_string , 1) = "i" Then 'Ausgabe Integer-Format mem0100I und mem0100,0020I
Print Mem_pos ; ":" ; Hex(mem_pos) ; "=" ;
Incr Mem_anfang ' Ausgabe von 2 byte, in umgedrehter Reihenfolge
I_temp = Mem(mem_anfang)
Shift I_temp , Left , 8
Decr Mem_anfang
I_temp = I_temp + Mem(mem_anfang)
Incr Mem_anfang
Incr Mem_pos
Print Hex(i_temp) ; ":" ; I_temp
Elseif Right(command_string , 1) = "L" Or Right(command_string , 1) = "l" Then 'Ausgabe Long-Format mem0100L und mem0100,0020L
Print Mem_pos ; ":" ; Hex(mem_pos) ; "=" ;
Mem_anfang = Mem_anfang + 3 ' Ausgabe von 4 byte, in umgedrehter Reihenfolge
L_temp = Mem(mem_anfang)
Shift L_temp , Left , 8
Decr Mem_anfang
L_temp = L_temp + Mem(mem_anfang)
Shift L_temp , Left , 8
Decr Mem_anfang
L_temp = L_temp + Mem(mem_anfang)
Shift L_temp , Left , 8
Decr Mem_anfang
L_temp = L_temp + Mem(mem_anfang)
Mem_anfang = Mem_anfang + 3
Mem_pos = Mem_pos + 3
Print Hex(l_temp) ; ":" ; L_temp
Elseif Right(command_string , 1) = "S" Or Right(command_string , 1) = "s" Then 'Ausgabe String-Format mem0100S und mem0100,0020S
Print Mem_pos ; ":" ; Hex(mem_pos) ; "=" ; Chr(34);
While Mem(mem_anfang) > 0
Print Chr(mem(mem_anfang));
Incr Mem_anfang
Incr Mem_pos
Wend
Print Chr(34)
End If
Incr Mem_anfang
Incr Mem_pos
Decr Mem_count
Wend
End If
'Ändern
Elseif Left(command_string , 1) = "c" Then
S_temp = Mid(command_string , 2 , 4)
Mem_anfang = Hexval(s_temp)
S_temp = Command_string
If Mem_anfang > &HFF Then Mem_anfang = Mem_anfang - &HFF
If Instr(command_string , ",") > 0 Then
B_temp = Instr(command_string , ",")
Incr B_temp
If Right(command_string , 1) = "B" Or Right(command_string , 1) = "b" Then 'Ändern von einem Byte, c0100,20b
S_temp = Mid(command_string , B_temp , 2)
Mem(mem_anfang) = Hexval(s_temp)
Elseif Right(command_string , 1) = "W" Or Right(command_string , 1) = "w" Then 'Ändern von einem Word, c0100,0020W
B_temp = B_temp + 2
S_temp = Mid(command_string , B_temp , 2)
Mem(mem_anfang) = Hexval(s_temp)
Incr Mem_anfang
B_temp = B_temp - 2
S_temp = Mid(command_string , B_temp , 2)
Mem(mem_anfang) = Hexval(s_temp)
Incr Mem_anfang
Elseif Right(command_string , 1) = "I" Or Right(command_string , 1) = "i" Then 'Ändern von einem Integer, c0100,0020I
B_temp = B_temp + 2
S_temp = Mid(command_string , B_temp , 2)
Mem(mem_anfang) = Hexval(s_temp)
Incr Mem_anfang
B_temp = B_temp - 2
S_temp = Mid(command_string , B_temp , 2)
Mem(mem_anfang) = Hexval(s_temp)
Incr Mem_anfang
Elseif Right(command_string , 1) = "L" Or Right(command_string , 1) = "l" Then 'Ändern von einem Long, c0100,00204060L
B_temp = B_temp + 6
S_temp = Mid(command_string , B_temp , 2)
Mem(mem_anfang) = Hexval(s_temp)
Incr Mem_anfang
B_temp = B_temp - 2
S_temp = Mid(command_string , B_temp , 2)
Mem(mem_anfang) = Hexval(s_temp)
Incr Mem_anfang
B_temp = B_temp - 2
S_temp = Mid(command_string , B_temp , 2)
Mem(mem_anfang) = Hexval(s_temp)
Incr Mem_anfang
B_temp = B_temp - 2
S_temp = Mid(command_string , B_temp , 2)
Mem(mem_anfang) = Hexval(s_temp)
Incr Mem_anfang
Elseif S_temp_ovly(7) = 34 Then 'Ändern von einem String, c0100,"123456"
B_temp = 8
If Right(command_string , 1) = Chr(34) Then
I_temp = Len(command_string) - B_temp
S_temp = Mid(command_string , B_temp , I_temp)
I_temp = 1
While S_temp_ovly(i_temp) <> 34
Mem(mem_anfang) = S_temp_ovly(i_temp)
Incr Mem_anfang
Incr I_temp
Wend
Mem(mem_anfang) = 0
End If
Else 'Ändern von mehreren Bytes, c0100,0020406080
I_temp = Len(command_string)
While B_temp < I_temp
S_temp = Mid(command_string , B_temp , 2)
Mem(mem_anfang) = Hexval(s_temp)
Incr Mem_anfang
B_temp = B_temp + 2
Wend
End If
End If
End If
Interrupt_flag.0 = 0
End If
Loop
Serial0charmatch:
Command_count = 0
Command_string = ""
While Ischarwaiting() = 1
Command_key = Inkey()
If Command_key <> Chr(13) Then
Incr Command_count
If Command_count < 100 Then
Command_string = Command_string + Chr(command_key)
End If
End If
Wend
Clear Serialin
Interrupt_flag.0 = 1
Return
End
Gruß
Lesezeichen