When using the addinterface command, you must specify the name of a procedure which will be called each time you access the memory. This procedure must have the following format :
proc routine {RW size addr value} {
if {$RW == "read"} {
puts "read $size $addr $value"
return ...something...
} else {
puts "write $size $addr $value"
...do something with value...
}
}
The RW parameter is set to read when you access the address to get a value, and set to write when you access the address to change the memory. The size indicates the size of the access which can be byte, word or long. The addr gives you the address, useful when you use addinterface with a entire area of memory. value is the value you want to write in memory, or 0 when you read the memory.
This short example shows you how to use interface memory. It use a scale (from 0 to 255) in a window. You can set the value of the scale, this value will be returned when you read the memory. When you write in it, the value of the scale is changed according to the written data.
This is a Tcl/Tk script for defining the scale (file named for example user.tcl) :
proc InitUser {} {
global input
catch {destroy .user}
toplevel .user
wm title .user "Interface"
wm iconname .user "User"
scale .user.input -from 0 -to 255 -length 100
-orient vertical -command "set input"
.user.input set 128
pack .user.input -side top -padx 10 -pady 10
}
proc routine {RW size addr value} {
global input
if {$RW == "read"} {
return $input
} else {
.user.input set $value
}
}
Just add the following line in your configuration file :
addinterface 0x10000000 0x10000000 routine
source user.tcl define interface
InitUser create the window
Then try this code :
move.b 0x10000000, d0
add.b #10, d0
move.b d0, 0x10000000