flat assembler
Message board for the users of flat assembler.
Index
> Main > SMSW: deprecated or not ? privileged or not ? PG useful ??? |
Author |
|
Japheth 02 Apr 2007, 06:39
> but MOV is privileged and SMSW ist't
yes > Seems to be a criminal design bug of 80386 yes > The thing returns always (mostly) $8000'0031 - "PG" bit is set SMSW copies a WORD only, the HiWord of the register is not affected. use debug.com to verify! ) |
|||
02 Apr 2007, 06:39 |
|
MazeGen 02 Apr 2007, 08:48
NTOSKRNL_VXE wrote: Well, it seems that SMSW and MOVing out from CR0 do exactly the same Probably do, but you can't never be 100% sure. Intel manual says "when the destination operand is a 32-bit register, the low-order 16 bits of register CR0 are copied into the low-order 16 bits of the register and the high-order 16 bits are undefined.", AMD says "SMSW reg32: Store the low 32 bits of CR0 to a 32-bit register." However, Intel probably copies whole CR0 in this case too. NTOSKRNL_VXE wrote: Seems to be a criminal design bug of 80386 Only in case you're sure it works... NTOSKRNL_VXE wrote:
Why don't you use the official manuals at the first place? Intel manual says "it is not a privileged instruction and can be used in application programs", AMD says "This instruction can be used at any privilege level". NTOSKRNL_VXE wrote: The thing returns always (mostly) $8000'0031 - "PG" bit is set, even if Swap file (paging file) has nothing with the paging mechanism itself. For instance, I run win xp with no paging file. Japheth wrote:
It works as described in the manuals for me - high word is always affected (OllyDbg always returns 8001003B, Turbo Debugger 80010031 for me). |
|||
02 Apr 2007, 08:48 |
|
Japheth 02 Apr 2007, 10:49
> It works as described in the manuals for me - high word is always affected
> (OllyDbg always returns 8001003B, Turbo Debugger 80010031 for me). apparently it depends. In 16-bit code AX is affected, in 32-bit code it is EAX. With prefix 66h one may switch (refering to "SMSW AX". Some assemblers don't accept EAX or ignore the 'E'). |
|||
02 Apr 2007, 10:49 |
|
DOS386 02 Apr 2007, 20:41
Thanks.
Quote: In 16-bit code AX is affected, in 32-bit code it is EAX. With prefix 66h one may switch (refering to "SMSW AX". Some assemblers don't accept EAX or ignore the 'E'). Seems that FASM accepts SMSW EAX and returns the same as MOV EAX,CR0 ... unsurprisingly, MOV works under HDPMI32 while under CWSDPMI it runs into a GPF Some texts imply SMSW EAX works on all CPU's except Cyrix (again ... UnrealMode, fool SB "emulation", ...) ... but since the upper 16 bits contain nothing except the PG bit which is always 1 in PM, there is no need for SMSW EAX anyway Quote: Swap file (paging file) has nothing with the paging mechanism itself. For instance, I run win xp with no paging file. Too many texts around spreading confusion or garbage It there any use of PM without paging at all ? What does this paging mean instead ? That I can have holes in RAM ? Can allocate and use RAM at $C0000000 (3 GB) although I have only 64 MB installed ? _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
02 Apr 2007, 20:41 |
|
Tomasz Grysztar 03 Apr 2007, 07:02
NTOSKRNL_VXE wrote: Too many texts around spreading confusion or garbage Read directly from the source - Intel manuals; they do not spread too much confusion. The paging mechanism is a mapping the linear addresses into physical ones. When paging is off, the linear address (the one you access, for example in "mov eax,[80000h]" you use linear address 80000h) is the same as physical address. With paging enabled you can map linear addresses into physical ones in various manners - each page (one page is 1000h byte with original 80386 paging) of linear address space can be mapped into any page in physical memory. You can also mark some pages as not present, so they will trigger an exception when some intruction tries to access that area - you can then handle that exception in order to make this area of memory available (useful for swap file, but also - for instance - to emulate linear framebuffer with banked VESA mode). As for the SMSW - it's very useful because of being unprivileged and for this reason MODES.INC uses it instead of "mov eax,cr0" - this is done to avoid protection triggering in Win 3.x and Win95 (the last one would display a message box asking whether you want to execute the program in DOS mode when a privileged instruction like "mov eax,cr0" is executed) - with SMSW your check for protected mode can go unnoticed. |
|||
03 Apr 2007, 07:02 |
|
DOS386 04 Apr 2007, 00:20
Thanks.
Quote: Read directly from the source - Intel manuals OK, but where to find the good ones ? - A manual for 80386 - A manual for P2 (simplest one with MMX/RDMSR/WRMSR/MTTRR) The newest "source" manuals getting linked from here contain 80% 64-bit stuff Quote: useful for swap file, but also - for instance - to emulate linear framebuffer with banked VESA mode Interesting hack _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
04 Apr 2007, 00:20 |
|
vid 04 Apr 2007, 00:56
Quote: OK, but where to find the good ones ? |
|||
04 Apr 2007, 00:56 |
|
MazeGen 04 Apr 2007, 07:23
Well, I always use the newest Intel and AMD manuals... Don't know what are the "good" ones. And yes, I own an archive of them.
BTW, there's nothing like deprecated instruction. An instruction is either supported or not. There are only a few old system instructions which are signed obsolete and which don't work anymore (because of changes to the processor's internal architecture), but that's surely not the case of SMSW. |
|||
04 Apr 2007, 07:23 |
|
Tomasz Grysztar 04 Apr 2007, 07:30
NTOSKRNL_VXE wrote: OK, but where to find the good ones ? Here was posted the 80386 manual in a text file form - this is actually the one I learned protected mode from. NTOSKRNL_VXE wrote:
DirectX was doing it on very old graphic cards, as I recall from Win95. |
|||
04 Apr 2007, 07:30 |
|
DOS386 13 Apr 2007, 00:01
Tomasz wrote:
Quote: Here was posted the 80386 manual in a text file form - this is actually the one I learned protected mode from Thanks. TXT is ZIPped, but compressed with Deflate64, no standard ZIP Maybe recompress with KZIP and re-upload ? MazeGen wrote: Quote: Well, I always use the newest Intel and AMD manuals... Don't know what are the "good" ones. Well, as written above, one for 80386 (as Tomasz pointed), and one for P1/P2, with MMX, MSR/MTRR, I/O debug, but without 64-bit and SSSSE stuff Quote: yes, I own an archive of them. Could you upload such a P2 manual please ? _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
13 Apr 2007, 00:01 |
|
rugxulo 24 May 2007, 07:32
FYI, Info-ZIP has supported unpacking Deflate64 since a fairly long while, I think (just tried it on 5.52, worked correctly), and it's free, extremely portable, good, etc., so ...
For a plain-text Pentium manual (XADD, CPUID, PACKUSWB, CMOVE, etc.), try ftp://ftp.sac.sk/pub/sac/text/pentium3.zip or search Alexei Frounze's page here (specifically under Optimization). |
|||
24 May 2007, 07:32 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.