1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Helper for common memory read/modify/write procedures
5 # mrw: "memory read word", returns value of $reg
7 return [read_memory
$reg 32 1]
10 add_usage_text mrw
"address"
11 add_help_text mrw
"Returns value of word in memory."
13 # mrh: "memory read halfword", returns value of $reg
15 return [read_memory
$reg 16 1]
18 add_usage_text mrh
"address"
19 add_help_text mrh
"Returns value of halfword in memory."
21 # mrb: "memory read byte", returns value of $reg
23 return [read_memory
$reg 8 1]
26 add_usage_text mrb
"address"
27 add_help_text mrb
"Returns value of byte in memory."
29 # mmw: "memory modify word", updates value of $reg
30 # $reg <== ((value & ~$clearbits) | $setbits)
31 proc mmw
{reg setbits clearbits
} {
33 set new
[expr {($old & ~
$clearbits) |
$setbits}]
37 add_usage_text mmw
"address setbits clearbits"
38 add_help_text mmw
"Modify word in memory. new_val = (old_val & ~clearbits) | setbits;"