How does x86 eflags bit 18 (alignment check) work? (Associated with checking for 386 versus 486 and later.)

I read that if the flag bit 18 (AC alignment check) can be changed, you know that the processor is 486 or newer. At 386 bits does not support modification.

I took the following assembler code from this site and added exhaustive comments (leaving the odd syntax intact):

asm
    mov  bx,sx            ; Save the stack pointer to bx (is sx a typo or a real register?).
    and  sp,$fffc         ; Truncate the stack pointer to a 4-byte boundary.
    pushfl                ; Push the eflags register to the stack.
    pop  eax              ; Pop it into eax.
    mov  ecx,eax          ; Save the original eflags value into ecx.
    xor  eax,$40000       ; Flip bit 18 in eax.
    push eax              ; Push eax to the stack.
    popfl                 ; Pop modified value into eflags.
    pushfl                ; Push eflags back onto the stack.
    pop  eax              ; Pop it into eax.
    xor  eax,ecx          ; Get changed bits from the original value.
    setz al               ; Set al register to 1 if no bits changed (0 otherwise).
    and  sp,$fffc         ; Truncate the stack pointer to a 4-byte boundary.
    push ecx              ; Push ecx (original eflags) to stack.
    popfl                 ; Pop it into eflags to restore the original value.
    mov  sp,bx            ; Restore the original stack pointer.
end ['eax','ebx','ecx'];

The CPU is 386 if in the al register it is set to 1 at the end (it is assumed that it is not older from the very beginning), otherwise 486 or later. I understand this part.

, , , 4- , ? , 18, ... xor 0x40000 . , , ?

, [] "": " , push/pop ? , 0 1. , ". (EDIT: , - , . , , pop/push .)

, , ( eflags )? 4- ? , / 4- ?

, , , - . - ?

( : "sx" bx. sx -. , ? "p", , .)

EDIT: , , . , , ( ). ( ), flolo sigbus. , .

+5
2

: sigbus. , , ( ). 4- , ? , . , ( ), , ( : , , , , ).

+4

SX. , .

+2

All Articles