mht
Wroclaw, Poland, 22.11.2008, 15:15 |
x86 flags after bit shifts with count = 0 (Developers) |
I needed to know what happens to the x86 flags after executing bit shift instructions (SHR, SHL, etc.) when the shift count given in CL is zero. Unfortunately, virtually all my books and electronic documentation only describe the cases CL = 1 and CL > 1. But I found that:
Intel(R) 64 and IA-32 Architectures Software Developer Manual, Vol. 2B: Instruction Set Reference on page 4-364 says that all flags remain unchanged if the shift count (CL mod 32) is zero.
Am186(TM) and Am188(TM) Family Instruction Set Manual says the same on page 252 and others.
Randall Hyde's The art of assembly language in page 29 of Chapter 6 also says the same.
So I guess I can assume this is true for all x86 processors... Anyone with original 8088/8086 manuals? |
Rugxulo
Usono, 25.11.2008, 06:47
@ mht
|
x86 flags after bit shifts with count = 0 |
> I needed to know what happens to the x86 flags after executing bit shift
> instructions (SHR, SHL, etc.) when the shift count given in CL is zero.
> Unfortunately, virtually all my books and electronic documentation only
> describe the cases CL = 1 and CL > 1.
Unless you're just really really curious or trying to write an x86 emulator, I can't see much use for this. But anyways ....
> So I guess I can assume this is true for all x86 processors... Anyone with
> original 8088/8086 manuals?
Dunno, don't have the manuals. Try bugging Jim Leonard to test on his 8088. Or find someone else online who has one (Dave Dunfield, perhaps?).
However, I wouldn't trust an emulator for this (e.g. Joris' Retro) since they all have bugs. |
ecm
Düsseldorf, Germany, 25.11.2008, 13:31
@ Rugxulo
|
x86 flags after bit shifts with count = 0 |
> Unless you're just really really curious or trying to write an x86
> emulator, I can't see much use for this. But anyways ....
No, it may also be useful when hacking some software written in assembly. Not that I needed to know this certain behaviour of shift instructions yet, but knowing such details often helps. --- l |
rr
Berlin, Germany, 25.11.2008, 21:21
@ Rugxulo
|
x86 flags after bit shifts with count = 0 |
> Or find someone else online who has one
> (Dave Dunfield,
> perhaps?).
As you probably remember I have several ATARI Portfolios (Intel 80C88) at my old workplace. If you are really keen on, I could go there this Thursday. --- Forum admin |
mht
Wroclaw, Poland, 25.11.2008, 21:59
@ rr
|
x86 flags after bit shifts with count = 0 |
Such a test would be nice, but please do not hurry. If possible, I prefer to find an evidence in official documentation -- then it should be guaranteed that all clones behave identically.
Tomorrow I will have a few additional books from a library. There is even the original Intel's 88/86 and 188/186 programmer's reference, but in an remote archive, so I will have to wait another day or two for it. |
rr
Berlin, Germany, 25.11.2008, 22:10
@ mht
|
x86 flags after bit shifts with count = 0 |
> Such a test would be nice, but please do not hurry.
If you could write a small test tool in the meantime ... --- Forum admin |
mht
Wroclaw, Poland, 25.11.2008, 22:11
@ ecm
|
x86 flags after bit shifts with count = 0 |
> Not that I needed to know this certain behaviour of shift instructions
> yet, but knowing such details often helps.
Indeed. Knowing precisely the processor's state helps to make code simpler. In this particular case I avoid treating the cases CL = 0 and CL > 0 separately and save a conditional jump. |
RayeR
CZ, 25.11.2008, 22:22
@ rr
|
x86 flags after bit shifts with count = 0 |
> As you probably remember I have several ATARI Portfolios (Intel 80C88) at
> my old workplace. If you are really keen on, I could go there this
> Thursday.
Are you ATARI Portfolio user?
I got this nice toy about 7 years ago, I also made my own 128k memory card and later extended internal RAM to 512k and made B: drive backuped by small battery.
Here's some photos but my site is CZ only, sorry.
But the coolest think I saw was a CF adapter. --- DOS gives me freedom to unlimited HW access. |
rr
Berlin, Germany, 26.11.2008, 20:57
@ RayeR
|
x86 flags after bit shifts with count = 0 |
> Are you ATARI Portfolio user?
I never really was. In 2005 (?) I bought four Pofos including several accessories on eBay, played a little, but put them away very soon, because I never was convinced from its battery-backed storage devices. Nevertheless I helped Klaus Peichl to debug his alternative file transfer program "TransFolio" for DOS/Win32/Linux.
> Here's some photos
> but my site is CZ only, sorry.
I know your pages, of course.
> But the coolest think I saw was a CF adapter.
(Created by Stefan Kächele) I've never seen this in action, but yes, it sounds very good. --- Forum admin |
Rugxulo
Usono, 28.11.2008, 00:09
@ rr
|
x86 flags after bit shifts with count = 0 |
> > Are you ATARI Portfolio user?
>
> I never really was. In 2005 (?) I bought four Pofos including several
> accessories on eBay, played a little, but put them away very soon, because
> I never was convinced from its battery-backed storage devices. Nevertheless
> I helped Klaus Peichl to debug his alternative file transfer program
> "TransFolio" for DOS/Win32/Linux.
It's too low in RAM and storage as well as having battery issues. Oh, and the screen is a weird size, and it's really underpowered. I mean, the world was a different place back then. It's not a big a deal now, but it's still (vaguely) cool. Something like the PoquetPC is probably more impressive (although I admit I never tried either). Who knows, maybe a Sharp Zaurus can run DOSEMU? But whenever you hear people doing such, it's usually for games. (Doesn't the GP2X or whatever have a partial DOSBox port?) --- Know your limits.h |
mht
Wroclaw, Poland, 28.11.2008, 07:17
@ rr
|
x86 flags after bit shifts with count = 0 |
> If you could write a small test tool in the meantime ...
Thanks for testing!
The test revealed that 80C88 keeps OF, SF, ZF, AF, PF and CF unchanged when the shift count is zero, exactly as documented for IA-32 processors. |
marcov
28.11.2008, 15:41
@ Rugxulo
|
x86 flags after bit shifts with count = 0 |
> It's too low in RAM and storage as well as having battery issues. Oh, and
> the screen is a weird size, and it's really underpowered. I mean, the
> world was a different place back then. It's not a big a deal now, but it's
> still (vaguely) cool. Something like the PoquetPC is probably more
> impressive (although I admit I never tried either). Who knows, maybe a
> Sharp Zaurus can run DOSEMU? But whenever you hear people doing
> such, it's usually for games. (Doesn't the GP2X or whatever have a partial
> DOSBox port?)
I've bought two IPaqs for FPC PocketPC development (one with PocketPC 2003 (wince4 iirc), the other with wince 5 (windows mobile 5).
I tried to get fast expandable ones, hx2750's, I can test if possible. |
rr
Berlin, Germany, 30.11.2008, 18:33
@ Rugxulo
|
x86 flags after bit shifts with count = 0 |
> It's too low in RAM and storage as well as having battery issues. Oh, and
> the screen is a weird size, and it's really underpowered.
It's not a big deal for a real DOS lover, but I really missed a floppy disk drive and display illumination. Yes, there was a backlight mod, but it was very expensive compared to the price of a used Pofo.
I also have the HP 200LX.
> still (vaguely) cool. Something like the PoquetPC is probably more
Used PoqetPCs are still available from http://www.cadigital.com/poqetpc.htm.
> impressive (although I admit I never tried either). Who knows, maybe a
> Sharp Zaurus can run DOSEMU? But whenever you hear people doing
> such, it's usually for games. (Doesn't the GP2X or whatever have a partial
> DOSBox port?)
A netbook like the Acer Aspire One is only "slightly" larger, but a real PC. --- Forum admin |
Rugxulo
Usono, 30.11.2008, 20:53
@ rr
|
x86 flags after bit shifts with count = 0 |
> > It's too low in RAM and storage as well as having battery issues. Oh,
> and
> > the screen is a weird size, and it's really underpowered.
>
> It's not a big deal for a real DOS lover,
Being so limited in RAM really hampers what you can run on it. I could live with 8086 (although most common stuff requires 386+), but the low RAM kills a lot of apps. Even with srcs, I'm not talented enough to hack everything to fit in such a cramped space.
Besides, the idea of using (button) batteries (which may be hard to find and unreliable) put me off, somewhat.
> but I really missed a floppy
> disk drive and display illumination. Yes, there was a backlight mod, but
> it was very expensive compared to the price of a used Pofo.
It took the Game Boy 13 years to get a backlight while Game Gear and Lynx had it in 1989. That's also why the latter each used much more batteries. (Original GB used 4 AA while GBC used only 2. Game Gear and Lynx II both used 6, I think.)
> I also have the HP 200LX.
Sounds cool from what little I've read of it. Still, maybe too hard to get working. Same with Sharp Zaurus. It's not that I'm unwilling to hack the thing, it's just gotta be reasonable based upon my own limitations.
> > still (vaguely) cool. Something like the PoquetPC is probably more
>
> Used PoqetPCs are still available from
> http://www.cadigital.com/poqetpc.htm.
Again, I've read about this before, but batteries are so unreliable (esp. used) that I never bothered. Plus, lack of RAM really kills most common programs.
> > impressive (although I admit I never tried either). Who knows, maybe a
> > Sharp Zaurus can run DOSEMU? But whenever you hear people doing
> > such, it's usually for games. (Doesn't the GP2X or whatever have a
> > partial DOSBox port?)
>
> A netbook like the Acer Aspire One is only "slightly" larger, but a real
> PC.
Smaller screen (something like 8") and keyboard as well as no optical drive, so these "netbooks" weigh typically 2.5 lbs or so (vs. my current laptop's 6.5 lbs). And speaking of crappy battery life, 6 cell gives me max. 2 hrs on this laptop (and that's on "Power Saver", meh). Oh well. Blame the RAM, USB, wifi, optical drive, widescreen, multi-core/superscalar, etc. for that. (Yeah, I could get a 12 cell, I guess. But I don't majorly need it.) There are really good laptops (12 hrs for some high-end Toshiba), but they are much more expensive. --- Know your limits.h |
Rugxulo
Usono, 30.11.2008, 21:06
@ Rugxulo
|
portable handhelds' battery life |
> It took the Game Boy 13 years to get a backlight while Game Gear and Lynx
> had it in 1989. That's also why the latter each used much more batteries.
> (Original GB used 4 AA while GBC used only 2. Game Gear and Lynx II both
> used 6, I think.)
Just to clarify, six batteries in a Lynx II wouldn't last more than "five to six hours" (according to Wikipedia), which I can verify from my personal experience. The Game Gear lasts a similar amount. But Game Boy (while technically inferior) had more games (not necessarily better ones, though) due to more third-party support yet was harder to view due to no backlight and (originally) no color (until GBC in 1998). And it wasn't until GBA SP (late 2001?) that it had built-in backlight and rechargeable battery. Luckily, it was fully backwards compatible (although the DS can also play GBA-only games). Even the PSP has only like 6 hrs. battery life, presumably due to its big screen. |
rr
Berlin, Germany, 30.11.2008, 22:38
@ Rugxulo
|
x86 flags after bit shifts with count = 0 |
> Being so limited in RAM really hampers what you can run on it. I could
> live with 8086 (although most common stuff requires 386+), but the low RAM
> kills a lot of apps. Even with srcs, I'm not talented enough to hack
> everything to fit in such a cramped space.
The Pofo hasn't been made for image processing.
> > A netbook like the Acer Aspire One is only "slightly" larger, but a
> real
> > PC.
>
> Smaller screen (something like 8") and keyboard as well as no optical
> drive, so these "netbooks" weigh typically 2.5 lbs or so (vs. my current
> laptop's 6.5 lbs). And speaking of crappy battery life, 6 cell gives me
> max. 2 hrs on this laptop (and that's on "Power Saver", meh). Oh well.
I've used the Aspire 150X for surfing the net for half an hour on Saturday and it worked very well. Good performance, no noise, clear and bright display, acceptable keyboard.
> guess. But I don't majorly need it.) There are really good laptops (12 hrs
> for some high-end Toshiba), but they are much more expensive.
Last Toshiba I saw (Portégé R500), was rather expensive, but very crappy. Please, no Toshi for me again! --- Forum admin |
RayeR
CZ, 30.11.2008, 22:41
@ rr
|
x86 flags after bit shifts with count = 0 |
> I also have the HP 200LX.
I know this nice machine, It's much better than pofo but pofo was very bastle friendly :) If would see it somewhere for reasonable price I'll get it. Currently I don't use porfolio much. I bought ipaq pocket PC (h2210 and later 214) and it offers me much much more. Even it can run DOSBOX hehe :)
I also had Olivetti Quaderno subnotebook with NEC V30 but HDD died. That Conner 20MB HDD was a real shit. I got one for replacement but it died few months later. And BIOS didn't accepted any elese HDD (Quaderno 386 AFAIK hadn't this problem). So I sold it. --- DOS gives me freedom to unlimited HW access. |
mht
Wroclaw, Poland, 05.12.2008, 08:55
@ mht
|
x86 flags after bit shifts with count = 0 |
Original Intel manual does not say explicitly that flags are left unchanged. It explains that SHR ARG, COUNT (other shift instructions are described similarly) is performed as follows:
argbefore := ARG;
temp := COUNT;
while (temp <> 0) do
begin
CF := LowestBit(ARG);
ARG := ARG div 2;
temp := temp - 1;
end;
if (COUNT = 1) then
if (HighestBit(argbefore) <> HighestBit(ARG)) then
OF := 1
else
OF := 0
else
OF := UNDEFINED;
and also says elsewhere that for all shift instructions, AF is undefined and SF, ZF and PF are set as usual. |