Page 1 of 1

PokeW & PeekW

Posted: Tue May 25, 2004 6:14 am
by KieranFoot
How do I implament pokew and peekw, so far I have peek and poke but no peekw and pokew :'(

Please can someone point me in the right direction ;D

Re:PokeW & PeekW

Posted: Tue May 25, 2004 6:49 am
by Pype.Clicker
what do you expect from pokew and peekw ? operate on shorts rather than long int ? If so, just mask/cast your values and voil? ...

Re:PokeW & PeekW

Posted: Tue May 25, 2004 6:58 am
by KieranFoot
I can do this in ASM. ???

Is an integer in c really one byte ???
May programming languages use 2 byte integers ???
What about C ???

Re:PokeW & PeekW

Posted: Tue May 25, 2004 7:29 am
by Schol-R-LEA
Actually, most C implementations use a 4 byte integer, but it's not universally so. IIRC, the C standard calls for the following bit widths:

char - 8 bits

w_char - 16 bits (this may be C++ only)

short int - at least 16 bits but no more than 32 bits

int - no less than the system implementation of short, but no more than the system implementation of long; usually 32 bits
in modern implementations

long int - at least 32 bits but no more than 64 bits

long long int - at least 64 bits

float - 32 bits

double - 48 or 64 bits

long double or double double - 96 bits

complex - the size of two ints (I think; this type as only introduced in the latest C standard, and AFAIK is not in C++)

I'm not entirely sure of this, as I have not seen the most recent standard; this is entirely from memory, as well. I am sure that Solar and others caan correct any errors I've made, for which I would be quite grateful.

In any case, there is simply no need for a peek() or poke() function in either C or assembly; in assembly, you can simply use 'mov AX, address' or the appropriate equivalent, while in C (assuing protected mode on the x86) you can simply cast the integer value of the address to the appropriate pointer type. To take an example from a real world case:

Code: Select all

char* text_page_0;

text_page_0 = (char*) 0xB8000; /* the beginning of the first text video page */
Perhaps it would help if you explained what you were trying to access, and why you wanted to use those functions to do so.