logs archiveIRC Archive / Undernet / #asm / 2006 / August / 29 / 1
dbtid
/op Asmodee`
asm
op me
:X
dbtid
riiiight
Int3
lo
Run
Anyone around?
BoR0
yup
Run
Is it normal that sall %cl, %eax only looks at the 5 least significant bits of %cl ?
BoR0
what is sall ?
Run
sorry - can you repeat your last line? I was flooded.
         

BoR0
what is sall ?
Run
I'm writing in C:
first = (1 << 32);
second = (1 << f());
Where f() returns 32.
first is set to 0 and second is set to 1.
The assembly code of the second line looks like:
call _Z1fv
movl %eax, %ecx
movl $1, %eax
sall %cl, %eax
movl %eax, second
dbtid
hey run
Run
hi
Do you know the answer?
BoR0
i see, so its a shift to the left. i assume the value of cl is 32
Run
By the way - the fact that I was flooded with some botnet the second I joined here -- could that be no coincidence? That would mean there is some script kiddie hanging out here.
dbtid
true enough
can't you hunt it down :)
what did the bot say?
Run
Too busy - I just ignore it.
[19:11] --- Received a CTCP YOU ArE ThE WeAkIst LiNk GoOdByE YOu ArE ThE WeAkIst LiNk GoOdByE YOu ArE ThE WeAkIst LiNk GoOdByE YOu ArE ThE WeAkIst LiNk GoOdByE YOu ArE ThE WeAkIst LiNk GoOdByE YOu ArE ThE WeAkIst LiNk GoOdByE from THT
Stuff like that - with colors.
dbtid
one second
BoR0
seems clear for me :)
dbtid
i got no such when i joined
you scared them away run
Run
O well, it happens more often. They never flood me off.
But the stupid client sends it to the same window as the channel that I'm in - that is annoying.
dbtid
looks like a gcc error
Run
Is there another assembly shift that would result in a 0 ?
BoR0
Run: is f() unsigned short int?
Run
no, an int
int f() { return 8 * sizeof(int); }
dbtid
sall is shift arithmetic left long?
BoR0
so you have a constant there
Run
BoR0: yes - if I use -O3 then second is set to 0 :p
dbtid
BoR0: but the compiler isn't treating it as such
         

Run
Hmm, someone just told me that according to C99 it is undefined behaviour.
How lame.
dbtid
what's undefined?
Run
x << 32;
I expected the result to be always 0 - but apparently not.
HIGHLY annoying :/
6.5.7 #3 "If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undened."
dbtid
If E1 has a signed
type and nonnegative value, and E1 ยด 2E2 is representable in the result type, then that is
the resulting value; otherwise, the behavior is undefined.
well, certainly it's not that the compiler is generating the wrong code.
the question is why using sall with a 1 and 32 gives you 1
BoR0
why dont you just set it to zero? why shifting
Run
It's not a constant
BoR0
i even get a warning when compiling code with >> 32 or << 32
Run
This was a test code, of course.
BoR0
: warning: right shift count >= width of type
Run
The real code is:
guint64 mask1 = ((guint64)1 << convert_colrow2index(col_start, row) + sign) - 1;
guint64 mask2 = ((guint64)1 << convert_colrow2index(col_end, row) + (1 - sign)) - 1;
result |= mask1 ^ mask2;
dbtid
guint64?
Run
glib
dbtid
for fun, if you did
guint64 one = 1;
Run
Basically, I'm trying to fill an unsigned int with a mask where bits n1 up till and including n2 are set.
dbtid
i'm assuming guint64 is 64 bits?
Run
dbtid: yes
dbtid
hm
that's odd then, because the compiler isn't using 64 bits for the result
not if it's doing what you showed
Run
The test case was for an int, which is 32 bits.
dbtid
yes, well, you *know* that's not going to work
Run
sh*t, i have to shop for food- shops almost close :(
sorry - bbiab
dbtid
that looks like something odd on the part of the compiler
bye bye
Run
back
dbtid
hi back
Run
lol
On the radio:
"Some woman asked herself, why can't I find a man who is sensitive and helpful, and who ALSO looks good? DJ: They exist, but they all already have a boy-friend."
Hmm, in dutch it sounds better
dbtid
they say the same things here
Run: do you know PeteD from #c?
(know who he is?)
Run
nope
[20:24] --- peteD :No such nick
dbtid
he lives near amsterdam
works for one of the isps there
oh well
Run
Anyway, I solved my problem.
guint64 mask1 = (sign << convert_colrow2index(col_start, row)) - 1;
guint64 mask2 = ((3 - sign) << convert_colrow2index(col_end, row)) - 1;
result |= mask1 ^ mask2;
Where sign is 1 or 2.
dbtid
yay
« prev