Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Address-of-a-variable/Tcl/address-of-a-variable-1.tcl
Normal file
21
Task/Address-of-a-variable/Tcl/address-of-a-variable-1.tcl
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package require critcl
|
||||
# This code assumes an ILP32 architecture, like classic x86 or VAX.
|
||||
critcl::cproc peek {int addr} int {
|
||||
union {
|
||||
int i;
|
||||
int *a;
|
||||
} u;
|
||||
|
||||
u.i = addr;
|
||||
return *u.a;
|
||||
}
|
||||
critcl::cproc poke {int addr int value} void {
|
||||
union {
|
||||
int i;
|
||||
int *a;
|
||||
} u;
|
||||
|
||||
u.i = addr;
|
||||
*u.a = value;
|
||||
}
|
||||
package provide poker 1.0
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package require poker
|
||||
|
||||
# Increment a memory location; this will probably crash if you try for real.
|
||||
# We don't define how to get a good address, but it's not usually a problem
|
||||
# for embedded programming...
|
||||
set where 0x12340
|
||||
poke $where [expr {[peek $where] + 1}]
|
||||
Loading…
Add table
Add a link
Reference in a new issue