Path: utzoo!censor!geac!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!unido!ira.uka.de!i30fs1!krey From: krey@i30fs1.ira.uka.de (Andreas Krey) Newsgroups: comp.lang.c Subject: Re: Dereferencing Typecast Integer Literals Message-ID: <91.035.15:59:53@ira.uka.de> Date: 4 Feb 91 15:59:53 GMT References: <22700@netcom.UUCP> Sender: news@ira.uka.de (USENET News System) Reply-To: krey@i30fs1.ira.uka.de (Andreas Krey) Organization: University of Karlsruhe, FRG Lines: 37 In article <22700@netcom.UUCP>, avery@netcom.UUCP (Avery Colter) writes: > I would like to know something. > > In BASIC (waiting for the groans to subside), there were the POKE, PEEK, > and CALL commands, which respectively store a value in a location, read > the present value of a location, or start executing a machine language > function starting at the location. > In C you may even define macros to make it more readable, but it IS system dependent... All macros cast the integer address to an appropriate pointer type and then dereference it to get the lvalue/function. #define LOC(x) (*((unsigned char*)(x))) #define CALL(x) (((void (*)())(x))()) *(void (*()))0xFC58() 'BASIC' <=> 'C' a=PEEK(b) <=> a=LOC(b); POKE(b,c) <=> LOC(b)=c; CALL(x) <=> CALL(x); If you want Parameters for Call: #define FUNC(x) ((void (*)())(x)) CALL(f,a,b) <=> FUNC(x)(a,b); (No Warranty for BASIC Syntax.) Andy ------------------------------------------- .signature: No such file or directory .signature: Still no such file or directory