LANGUAGE & SOVEREIGN INSTRUCTION SPECIFICATION

xLang & ZAsm Official Specification

The direct evolutionary descendant of Terry A. Davis's HolyC compiler, re-engineered for 16-bit UCS-2 Hanzi parsing and sovereign register semantics at processor Ring 0.

1. Language Philosophy: Code as First-Class Text & Instant JIT

xLang dissolves the traditional boundaries between scripting languages, bytecode virtual machines (such as the JVM), and compiled binaries (ELF/PE). Every line entered into the xHunOS terminal is compiled in memory within 1 millisecond into native x86-64 machine code and executed instantly.

The shell IS the compiler, and the editor IS the runtime. In xLang, source code integrates seamlessly into the DolDoc hypertext system. Once declared, any function can be invoked across the single flat address space by any task via direct memory pointers, without dynamic library (DLL/.so) loading penalties.

Core Architectural Insight:In xHunOS, there are no binary packaging artifacts (.exe, .bin). All system tools, metaphysical algorithms, and hardware drivers reside as source files directly in DaoFS flash sectors, compiled dynamically upon invocation.
// xLang interactive REPL live evaluation example:
> 常数 爻数 = 6;
> 函数 打印天命() {
    终端输出("乾卦六爻已就绪\n");
  }
> 打印天命();
[OK] JIT compiled in 0.0004s, direct to framebuffer bus

2. Native 16-Bit UCS-2 Fixed-Width Chinese Tokenizer

Mainstream compilers treat non-Latin text as variable-length UTF-8 sequences, requiring dynamic pointer slicing and string boundary validations. xLang is built natively on a fixed 16-bit UCS-2 character encoding.

During lexical tokenization, each Chinese ideograph aligns to a 2-byte machine word, achieving O(1) lexical parsing directly from raw source code into the AST without byte-slice overhead.

xLang Core Hanzi Keyword Reference
Keyword (Hanzi)HolyC / C EquivalentCompiler Behavior & Semantics
常数const / #defineCompile-time constant literal emitted directly as immediate operand
变量var / autoStack or global variable binding directly to general-purpose registers
函数U0 / fnExecutable function entry point, compiled to machine code in <1ms
若 / 否则if / elseHigh-speed conditional branching evaluated against BaGua CPU flags
循环for / whileZero-overhead loop primitive utilizing register 丙 (RCX)
返回returnPlaces result in register 甲 (RAX) and restores caller stack frame
结构class / structPacked, zero-padding contiguous memory struct definition
公用public / externExports symbol globally into TaiChu's root symbol table

3. ZAsm: 64-Bit Sovereign Register & Condition Flags

ZAsm is the sovereign machine assembly layer executing directly on x86-64 hardware. Rejecting western alphabetical mnemonics, it maps 64-bit general-purpose CPU registers to the Ten Heavenly Stems and binds condition flags to the Eight Trigrams.

By establishing autonomous register and instruction semantics, ZAsm-generated machine code is inherently immune to automated pattern recognition and vulnerability scanning by conventional decompilers (such as IDA Pro and Ghidra).

Ten Heavenly Stems 64-Bit GPR Alias Map
Heavenly Stemx86-64 RegisterHardware Architectural Convention
甲 (Jia)RAXPrimary accumulator · Primary return value register
乙 (Yi)RBXBase register · Heap memory base physical pointer
丙 (Bing)RCXCounter register · Shift and divination loop counter
丁 (Ding)RDXData register · Direct hardware I/O and entropy buffer
戊 (Wu)RSISource index register · DaoFS flash sector read pointer
己 (Ji)RDIDestination index register · Framebuffer write pointer
庚 (Geng)RBPStack frame base pointer · Task stack anchor
辛 (Xin)RSPStack top physical pointer · Hardware push/pop pointer
BaGua Branch Condition Flag Bindings
Trigram BranchBound CPU FlagMathematical Branch Condition
遇乾则跳CF (Carry Flag)Pure Yang · Jump if unsigned addition carry or subtraction borrow occurs
遇坤则跳ZF (Zero Flag)Pure Yin · Jump if arithmetic result is zero or equality test matches
遇震则跳SF (Sign Flag)Thunder · Jump if most significant bit is 1 (negative polarity)
遇坎则跳OF (Overflow Flag)Water · Jump if signed integer arithmetic undergoes overflow

4. Comparative Language Evolution: Standard C vs. HolyC vs. xLang

Language DialectCompilation & Execution ModelCharacter StandardRegister Semantics
Standard C (C11/C23)Preprocess -> Compile -> Assemble -> Link -> BinaryASCII / Variable UTF-8 slicingRAX / RBX / RCX / RDX (Western naming)
HolyC (TempleOS)JIT compiled into RAM · No linking phase8-Bit Extended ASCII (with graphics)RAX / RBX / RCX / RDX bare-metal access
xLang (xHunOS)Sub-millisecond JIT directly to machine codePure 16-Bit UCS-2 Native Hanzi TokensTen Heavenly Stems + Eight Trigrams