peeking and pokeing.
- Posted by Hayden McKay <hmck1 at dodo.com.au> Feb 19, 2005
- 454 views
pokes 8,16,24 or 32 bits into a memory location. Eliminates if..elsif..end if statements.
include bits.e -- define_asm_proc()
sequence asm_code asm_code={
- 55,#89,#E5,#52,#51,#53,#56,#57,#8B,#45,#08,#8B,#7D,#0C,#3D,#FF,#00,#00,#00,#76,
- 15,#3D,#FF,#FF,#00,#00,#76,#12,#3D,#FF,#FF,#FF,#00,#76,#10,#83,#F8,#FF,#76,#31,
- EB,#33,#88,#07,#EB,#2F,#66,#89,#07,#EB,#2A,#BA,#FF,#7F,#00,#00,#80,#FA,#7F,#74,
- 02,#EB,#0D,#88,#07,#88,#67,#01,#C1,#E8,#08,#88,#67,#02,#EB,#11,#88,#47,#02,#88,
- 67,#01,#C1,#E8,#08,#88,#27,#EB,#04,#89,#07,#EB,#00,#5A,#59,#5B,#5E,#5F,#C9,#C3} --100
constant pokeXasm=define_asm_proc(asm_code[1..100],{DWORD,DWORD},4) {value,addr}
global procedure pokeX(atom address, atom value) c_proc(pokeXasm,{value,address}) end procedure <\eucode>
NOTE: Both little endian and big endian machines are supported. Jumps out if "value" > #FFFFFFFF. (Wrote it to poke bytes into a linear frame buffer or virtual screen) }}}