flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > High Level Languages > [solved]pointer & 0xFFF

Author
Thread Post new topic Reply to topic
vivik



Joined: 29 Oct 2016
Posts: 376

[solved]pointer & 0xFFF

I tried to do this:

int* pointer = whatever;
if (pointer & 0xFFF == 0) dosomething();

Didn't compile.

Tried this:

if (((int)pointer) & 0xFFF == 0) dosomething();

And it follows (dereferences) the pointer, instead of using the address of the pointer itself.

I'm doing the craziest shit, ain't I?


Last edited by vivik on 25 Feb 2018, 05:34; edited 1 time in total
Post 24 Feb 2018, 20:53
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2279
Location: Usono (aka, USA)

I'm no C pro (or is this C++ ?), but I'm not sure exactly what you're trying to do.

But beware precedence levels. So, while it doesn't fix your problem, be careful of this:


Quote:

blah & 0xFFF == 0

... versus ...

(blah & 0xFFF) == 0

Post 24 Feb 2018, 22:27
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2279
Location: Usono (aka, USA)

You may also wish to use stdint.h 's intptr_t and uintptr_t .
Post 24 Feb 2018, 23:16
View user's profile Send private message Visit poster's website Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 376

Perfect, thank you! This worked:

if (((intptr_t)pointer & 0xFFF) == 0) break;
Post 25 Feb 2018, 05:31
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2018, Tomasz Grysztar.
Powered by rwasa.