x86 & x86-64 (archsem-x86)
archsem-x86 defines the x86 architecture manifest (X86_MANIFEST), register map (regmap), semantic table (X86_SEMANTICS), Asem-generated programs (programs), and—when the optional iced feature is enabled—the iced-x86 decoder adapter, form identity catalog, and performance scenario model.
# Pure data only (no decoder dependency):
archsem-x86 = "0.1"
# With iced-x86 decoder, form catalog, and performance adapters:
archsem-x86 = { version = "0.1", features = ["iced"] }
CPU Modes & Segmentation
X86_MANIFEST declares three CpuModes sharing one unified semantic table:
| Constant | Bit Width | SegSemantics | Description |
|---|---|---|---|
LONG64 | 64-bit | SegSemantics::None | Long / 64-bit mode (FS/GS linear bases modeled explicitly) |
PROT32 | 32-bit | SegSemantics::Descriptor | 32-bit protected mode (with optional architectural segmentation checks) |
REAL16 | 16-bit | SegSemantics::RealMode | 16-bit real-address mode |
Address formation uses SegmentationModel::Flat by default. Selecting SegmentationModel::Architectural (via RtlEmitter::with_segmentation_model or CfgLiftConfig::segmentation_model) routes 16-bit real-mode, virtual-8086, and 32-bit protected accesses through hidden descriptor caches with guarded #GP/#SS limit and attribute checks, plus descriptor-table/gate/IRETQ semantics and Require modeled-domain preconditions.
Decoder Adapter (iced Feature)
Enabling features = ["iced"] unlocks archsem_x86::decode:
IcedX86Decoder: Stateless default Intel-personalityDecoder<Insn = IcedInsn, State = NoDecodeState>.IcedX86DecoderWithOptions(pub u32): Selects vendor/historical opcode personalities:AMD— AMD decode differences (honours66operand-size prefix on near branches in 64-bit mode,UD0without ModRM,LOCK MOV CR0asMOV CR8, etc.)KNC— Intel Knights Corner (MVEXand KNC VEX maps in 64-bit mode)- Legacy/vendor personalities:
CYRIX,LOADALL286,LOADALL386,UMOV,XBTS,CYRIX_SMINT_0F7E,CYRIX_DMI,ALTINST,STOREALL,CL1INVMB,UDBG,POP_CS
#UDHandling: Complete invalid encodings (Code::INVALID) lift through theUD2semantic row (#UDtrap) rather than failing as truncated input.
Register Aliasing, Flags, and REP Loops
- GPRs (
cid0..16):RAX–R15useSubRegMap::X86Nested:- 8-bit low (
AL) and high (AH,offset = 8) and 16-bit (AX) writes useRegisterWritePolicy::Preserve. - 32-bit (
EAX) writes useRegisterWritePolicy::ZeroExtendParentinto the 64-bit parent (RAX).
- 8-bit low (
- Status Flags (
CarryPolarity::BorrowSet):CF,PF,AF,ZF,SF,OF, andDFare modeled as individual 1-bitRegisterRole::Flagregisters (cid1..7), whileRFLAGS_CONTROLholds the remaining non-condition bits. - String Operations (
REP/REPE/REPNE): Expand viaControlEffect::Repinto executableRoot/RepeatBody/RepeatLatchInstructionExecutionGroups.REPE/REPNECMPS/SCASrun each iteration in the latch and commit final flags on the terminating iteration, preserving pre-instructionEFLAGSbeside committedRCX/RSI/RDIprogress if a later iteration faults. - Atomic Routes:
XCHGwith a memory destination andLOCK-prefixed memory-destination RMW instructions selectprograms::atomic_program_forand emitAtomicEvents; illegalLOCKcombinations fail closed before emission.
x87, MMX, SIMD, AVX-512, and MVEX
- x87 FPU (
x87_exact.asem,x87_projection.asem,x87_state_image.asem): Models the 80-bitST(0)..ST(7)stack (IndexedRegisterBank),FPCW,FPSW(reconstructing liveX87_TOP),FPTW, and state-image layouts (FXSAVE/FXRSTOR,FNSAVE/FRSTOR,FNSTENV/FLDENV). - MMX (
mmx.asem): Decoded operands touchingMM0..MM7dispatch to dedicated x87-aliased routes rather than silently aliasing XMM vectors. - SSE / AVX / AVX-512 (
VEC_BASE = 0x100,K_BASE = 0x90):XMM/YMM/ZMMalias a single 512-bit parent (SubRegMap::VectorNested); legacy SSE writes preserve upper lanes while VEX/EVEX/XOP writes clear them.- EVEX write masking (
{k1}/{z}), embedded rounding ({rn-sae}), SAE,{1toN}broadcast, and fault-suppressed masked memory loads (E##vsE##NFwithprobe_write) are modeled explicitly. - AVX-512 scatter programs declare
TransactionModel::Progressive.
- Crypto / Math Expansion: AES, SHA, SM3/SM4, and x87 transcendentals stay compact structured
OpaqueIntrinsics by default unlessIrEmitter::opaque_expansion()enablesOpaqueExpansion::CRYPTOorMATH.
Architecture Profiles, Form & Performance Catalogs
- Profiles (
X86_ARCHITECTURE_PROFILES):X86_PROFILE_BASELINE,LEGACY_BASE,X87,LEGACY_MMX,SSE,AVX,AVX512,CRYPTO,MVEX,OTHER_EXTENSION. - Form Catalog (
archsem_x86::form): Assigns stable, versionedX86FormIddigests (architectura.x86.form.v1) from symbolicicedCodenames andX86ExecutionModes (13,028reviewediced1.21.0 forms), independent of unstable enum discriminants. - Performance Catalog (
archsem_x86::performance): Models CPU tuning IDs (X86Microarchitecture),ResolvedX86Scenario, latency/throughput records (X86PerformanceDatabase), and macro/micro-fusion rules imported offline fromuops.infoviaarchsem-uops-info.