<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2014-05-05 20:37 GMT+02:00 Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br><div dir="ltr">Hi Nicolai,<div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 5, 2014 at 12:06 AM, Nicolai Hess <span dir="ltr"><<a href="mailto:nicolaihess@web.de" target="_blank">nicolaihess@web.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2014-04-03 17:51 GMT+02:00 karl ramberg <span dir="ltr"><<a href="mailto:karlramberg@gmail.com" target="_blank">karlramberg@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br><div dir="ltr">I can confirm this bug on windows Cog.<div><br></div><div>Cheers,</div><div>Karl</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 3, 2014 at 10:11 AM, Nicolai Hess <span dir="ltr"><<a href="mailto:nicolaihess@web.de" target="_blank">nicolaihess@web.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br><div dir="ltr"><div><div><div><div><div>There is still something wrong with byte/word swap in windows ioShowDisplay code<br>
attached are two screenshots<br></div>squeak 4.5 image with cogvm from <a href="http://files.pharo.org/vm/cogmt/win/" target="_blank">http://files.pharo.org/vm/cogmt/win/</a><br>
</div>pharo 30793 image with latest vm from <a href="http://files.pharo.org/vm/pharo/win/" target="_blank">http://files.pharo.org/vm/pharo/win/</a><br></div><div>showing this bug after setting the Display depth to 16<br>
(Display newDepth:16)<br>
<br></div>sqwin32window.c has three variants for doing the byte_swap/word_swap on<br></div>bitdepths with big endian to convert to lsb<br><br></div>This one is active and causes this error.<br><div><div><div><div><div><div>
<div># if __GNUC__ >= 3<br># define BYTE_SWAP(w) __asm__("bswap %0" : "=r" (w) : "r" (w))<br># define WORD_SWAP(w) __asm__("roll $16, %0" : "=r" (w) : "r" (w))<br>
<br></div><div>This one would work<br># else<br># define BYTE_SWAP(w) __asm__("bswap %%eax" : "=eax" (w) : "eax" (w))<br># define WORD_SWAP(w) __asm__("roll $16, %%eax" : "=eax" (w) : "eax" (w))<br>
<br>This one, of course, works too<br># else<br># define BYTE_SWAP(w) w = (w << 24) | ((w & 0xFF00) << 8) | ((w >> 8) & 0xFF00) | (w >> 24)<br># define WORD_SWAP(w) w = (( (unsigned)(w) << 16) | ((unsigned) (w) >> 16))<br>
<br></div><div>This one is not there but would work (at least with gcc > 4.5<br># define BYTE_SWAP_MY(w) __asm__("bswap %0" : "+r" (w))<br># define WORD_SWAP_MY(w) __asm__("roll $16, %0" : "+r" (w))<br>
<br></div><div>But actually I don't know assembler and/or the gcc inline code syntax, so<br>I don't know what is wrong with the first version :)<br><br></div><div>Nicolai<br><br></div><div>btw, you can not test this bug with the current squeak 4.5 all in on image,<br>
as it uses a rather old vm.<br><br>Third screenshot: <br>using the latest stable pharo-vm, it looks much more wrong, as there<br>was another(?) bug that is fixed already(?) - i don't know :)<br><br></div><div><br></div>
</div></div></div></div></div></div></div>
<br></blockquote></div><br></div>
<br></blockquote></div><br><br><br></div><div class="gmail_extra">Someone else can reproduce this?<br></div><div class="gmail_extra">(eliot?, nicolas? )<br></div><div class="gmail_extra">It is easily fixable, I think. But I am not good at inline assembler.<br>
</div><div class="gmail_extra">I'll open a mantis and fogbugz report.</div><div class="gmail_extra"><br></div></div></blockquote><div>Yes, I can reproduce it. But I've not had time to check with a pre 3.x and a post 3.x compiler to check what the right syntax is. I'm busy with other stuff right now. Hopefully I'll get to this in a coupel of weeks. Anyone else out there who can provide the right syntax for</div>
<div><br></div><div>2.95</div><div>3.4.x</div><div>4.x</div><div><br></div><div>I'd be very grateful and simply integrate the fix. </div></div><br><div>-- <br></div>best,<div>Eliot</div>
</div></div>
<br></blockquote></div><br><br></div><div class="gmail_extra">Ok, thank you eliot. <br></div><div class="gmail_extra">I think I know now way the first version does not work:<br> __asm__("bswap %0" : "=r" (w) : "r" (w))<br>
</div><div class="gmail_extra">The compiler might generate code like this, just:<br><br></div><div class="gmail_extra">bswap %ebx<br><br></div><div class="gmail_extra">without initialisation of that register (although we declare "r"(w) as input).<br>
It behaves like that, because an output register is supposed to be overwritten :)<br></div><div class="gmail_extra">and the bswap command only uses the %0 (the first register in the output : input register list).<br><br>
</div>
<div class="gmail_extra">The proper way for defining an register as output-input (or read-write register) would be<br></div><div class="gmail_extra"> __asm__("bswap %0" : "+r" (w) )<br></div><div class="gmail_extra">
Some asm-inline tutorials mention, this(the "+" constraint modifier) would not work on all compilers and <br>prefer another older syntax:<br> __asm__("bswap %0" : "=r" (w) : "0" (w))<br>
</div><div class="gmail_extra">(use the 0th output register for input too)<br><br></div><div class="gmail_extra">But even the gcc2.95 doc (<a href="http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_16.html#IDX955" target="_blank">http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_16.html#IDX955</a>)<br>
lists "+" as allowed constraint modifier, so, I think it should work.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">I'll test this with different gcc versions and compare the compiler output<br>
</div><div class="gmail_extra">
(after I found out how to install multiple mingw versions :) )<br><br><br></div><div class="gmail_extra">nicolai<br><br></div><div class="gmail_extra"><br></div></div>