1. Poking and peeking C_USHORT
- Posted by Jonas Temple <jktemple at yhti.net> Oct 12, 2001
- 350 views
Okay...here's the question.... When a dll function calls for a pointer to an short (signed or unsigned) what is the preferred method of poking and peeking the data? I am working on wrapping several dlls and it calls for short data type. I used peek() and then bytes_to_int() but bytes_to_int expects a sequence with a length of 4. Since the data is only two bytes, what is the easiest way to translate back to an atom? Any help would be greatly appreciated. Jonas
2. Re: Poking and peeking C_USHORT
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 12, 2001
- 371 views
Try this --(for intel machines)... atom addr -- Pointer to memory atom val -- peeking val = 256 *peek(addr) + peek(addr+1) --poking poke(addr, {floor(val / 256), and_bits(val, 256)}) --(for non-intel machines)... -- peeking val = 256 *peek(addr+1) + peek(addr) --poking poke(addr, {and_bits(val, 256),floor(val / 256) }) ----- Original Message ----- From: "Jonas Temple" <jktemple at yhti.net> To: "EUforum" <EUforum at topica.com> Sent: Saturday, October 13, 2001 1:24 PM Subject: Poking and peeking C_USHORT > > Okay...here's the question.... > > When a dll function calls for a pointer to an short (signed or unsigned) > what is the preferred method of poking and peeking the data? I am > working on wrapping several dlls and it calls for short data type. > > I used peek() and then bytes_to_int() but bytes_to_int expects a > sequence with a length of 4. Since the data is only two bytes, what is > the easiest way to translate back to an atom? > > Any help would be greatly appreciated. > > Jonas > > >
3. Re: Poking and peeking C_USHORT
- Posted by Rolf Schröder <r.schr at t-online.de> Oct 13, 2001
- 385 views
This is a multi-part message in MIME format. --------------944CF34B5422BA5AC0F0A992 Here is attached an zipped include file. It contains three routines: poke(), peeku(), peeks(). Truly 16 bit reading and writing! Enjoy, and have a nice day, Rolf --------------944CF34B5422BA5AC0F0A992 name="Words.e"
4. Re: Poking and peeking C_USHORT
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 13, 2001
- 376 views
Absolutely nothing. Did I say that there was? The version you displayed might be a tad slower but that might not be important. As we all keep learning everyday: in programming there is ALWAYS more than one way to achieve the desired outcome. ----- Original Message ----- From: <bensler at mail.com> To: "EUforum" <EUforum at topica.com> Subject: RE: Poking and peeking C_USHORT > > What's wrong with this? > > sequence temp_val > atom val > > val = bytes_to_int(peek({addr,2})&{0,0}) > > temp_val = int_to_bytes(val) > poke(addr,temp_val[1..2]) > > > Chris > > > Derek Parnell wrote: > > Try this > > > > --(for intel machines)... > > > > atom addr -- Pointer to memory > > atom val > > > > -- peeking > > val = 256 *peek(addr) + peek(addr+1) > > --poking > > poke(addr, {floor(val / 256), and_bits(val, 256)}) > > > > --(for non-intel machines)... > > -- peeking > > val = 256 *peek(addr+1) + peek(addr) > > --poking > > poke(addr, {and_bits(val, 256),floor(val / 256) }) > > > > > > ----- Original Message ----- > > From: "Jonas Temple" <jktemple at yhti.net> > > To: "EUforum" <EUforum at topica.com> > > Sent: Saturday, October 13, 2001 1:24 PM > > Subject: Poking and peeking C_USHORT > > > > > > > Okay...here's the question.... > > > > > > When a dll function calls for a pointer to an short (signed or unsigned) > > > > > > what is the preferred method of poking and peeking the data? I am > > > working on wrapping several dlls and it calls for short data type. > > > > > > I used peek() and then bytes_to_int() but bytes_to_int expects a > > > sequence with a length of 4. Since the data is only two bytes, what is > > > the easiest way to translate back to an atom? > > > > > > Any help would be greatly appreciated. > > > > > > Jonas > > > > > > > >