POKE, PEEK
pik33
Posts: 2,366
A Basic without these is not complete.
FlexBasic is flexible, so I wrote a fast workaround for this problem:
function peek(addr) as ubyte dim r as ubyte asm rdbyte r,addr end asm return r end function function dpeek(addr) as ushort dim r as ushort asm rdword r,addr end asm return r end function function lpeek(addr) as ulong dim r as ulong asm rdlong r,addr end asm return r end function sub poke(addr as ulong,value as ubyte) asm wrbyte value, addr end asm end sub sub dpoke(addr as ulong,value as ushort) asm wrword value, addr end asm end sub sub lpoke(addr as ulong,value as ulong) asm wrlong value, addr end asm end sub
Comments
ASM... meh... why didn't I think of that?
;-)
I've 2 variants in my heap of snippets.
Casting felt natural for me often thinking in C:
http://yeti.freeshell.org/orgy/flexprop/flexprop.html#:flexbasic:example:cast
The other one was mentioned in a flexspin thread:
http://yeti.freeshell.org/orgy/flexprop/flexprop.html#:flexbasic:example:peekpoke