x86 is an octal machine
本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。
Instantly share code, notes, and snippets. seanjensengrey/octal_x86.txt Last active November 28, 2026 00:15 Show Gist options Download ZIP Star 169 (169) You must be signed in to star a gist Fork 30 (30) You must be signed in to fork a gist Embed Select an option Embed Embed this gist in your website. Share Copy sharable link for this gist. Clone via HTTPS Clone using the web URL. No results found Learn more about clone URLs Clone this repository at <script src=“https://gist.github.com/seanjensengrey/f971c20d05d4d0efc0781f2f3c0353da.js"></script> Save seanjensengrey/f971c20d05d4d0efc0781f2f3c0353da to your computer and use it in GitHub Desktop.
即时分享代码、笔记和片段。seanjensengrey/octal_x86.txt 最后活跃于 2026 年 11 月 28 日 00:15。显示 Gist 选项,下载 ZIP,加星 169 (169),您必须登录才能为 gist 加星,分支 30 (30),您必须登录才能分支 gist。嵌入:选择一个选项,将此 gist 嵌入您的网站。分享:复制此 gist 的可共享链接。通过 HTTPS 克隆,使用 Web URL 克隆。未找到结果,了解有关克隆 URL 的更多信息。将此存储库克隆到 <script src=“https://gist.github.com/seanjensengrey/f971c20d05d4d0efc0781f2f3c0353da.js"></script>,保存 seanjensengrey/f971c20d05d4d0efc0781f2f3c0353da 到您的计算机并使用 GitHub Desktop。
x86 is an octal machine. Raw octal_x86.txt. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters. Show hidden characters.
x86 是一台八进制机器。原始 octal_x86.txt。此文件包含隐藏或双向 Unicode 文本,其解释或编译方式可能与下方显示的内容不同。如需查看,请在显示隐藏 Unicode 字符的编辑器中打开该文件。了解有关双向 Unicode 字符的更多信息。显示隐藏字符。
source:http://geocities.com/SiliconValley/heights/7052/opcode.txt From: mark@omnifest.uwm.edu (Mark Hopkins) Newsgroups: alt.lang.asm Subject: A Summary of the 80486 Opcodes and Instructions (1) The 80x86 is an Octal Machine. This is a follow-up and revision of an article posted in alt.lang.asm on 7-5-92 concerning the 80x86 instruction encoding. The only proper way to understand 80x86 coding is to realize that ALL 80x86 OPCODES ARE CODED IN OCTAL. A byte has 3 octal digits, ranging from 000 to 377. In fact, each octal group (000-077, 100-177, etc.) tends to encode a specific variety of operation. All of these are features inherited from the 8080/8085/Z80. For some reason absolutely everybody misses all of this, even the Intel people who wrote the reference on the 8086 (and even the 8080).
来源:http://geocities.com/SiliconValley/heights/7052/opcode.txt 发件人:mark@omnifest.uwm.edu (Mark Hopkins) 新闻组:alt.lang.asm 主题:80486 操作码和指令摘要 (1) 80x86 是一台八进制机器。这是对 1992 年 7 月 5 日发布在 alt.lang.asm 上关于 80x86 指令编码文章的后续和修订。理解 80x86 编码的唯一正确方法是意识到所有 80x86 操作码都是以八进制编码的。一个字节有 3 个八进制数字,范围从 000 到 377。事实上,每个八进制组(000-077, 100-177 等)往往编码特定种类的操作。所有这些都是从 8080/8085/Z80 继承的特性。出于某种原因,几乎每个人都忽略了这一点,甚至包括编写 8086(甚至 8080)参考手册的英特尔员工。
The opcode scheme outlined briefly below is expanded starting in the 80386, but consistently with the overall scheme here. As an example to see how this works, the mov instructions in octal are: 210 xrm mov Eb, Rb; 211 xrm mov Ew, Rw; 212 xrm mov Rb, Eb; 213 xrm mov Rw, Ew; 214 xsm mov Ew, SR; 216 xsm mov SR, Ew.
下面简要概述的操作码方案从 80386 开始进行了扩展,但与此处的整体方案保持一致。作为一个例子,看看它是如何工作的,八进制的 mov 指令如下:210 xrm mov Eb, Rb;211 xrm mov Ew, Rw;212 xrm mov Rb, Eb;213 xrm mov Rw, Ew;214 xsm mov Ew, SR;216 xsm mov SR, Ew。
The meanings of the octal digits (x, m, r, s) and their correspondence to the operands (Eb, Ew, Rb, Rw, SR) are the following: The digit r (0-7) encodes the register operand as follows: REGISTER (r): 0 1 2 3 4 5 6 7. Rb = Byte-sized register AL CL DL BL AH CH DL BH. Rw = Word-sized register AX CX DX BX SP BP SI DI. The segment register digit s (0-7) encodes the segment register as follows: SEGMENT REGISTER (s): 0 1 2 3 4 5 6 7. SR = Segment register ES CS SS DS
八进制数字 (x, m, r, s) 的含义及其与操作数 (Eb, Ew, Rb, Rw, SR) 的对应关系如下:数字 r (0-7) 对寄存器操作数进行编码,如下所示:寄存器 (r): 0 1 2 3 4 5 6 7。Rb = 字节大小寄存器 AL CL DL BL AH CH DL BH。Rw = 字大小寄存器 AX CX DX BX SP BP SI DI。段寄存器数字 s (0-7) 对段寄存器进行编码,如下所示:段寄存器 (s): 0 1 2 3 4 5 6 7。SR = 段寄存器 ES CS SS DS <保留>。
The digits x (0-3), and m (0-7) encode the address mode according to the following scheme. One or more bytes (labeled: Disp) may immediately follow xrm as described below. TABLE 1: 16-BIT ADDRESSING MODE (x, m): Eb = Address of byte-sized object in memory or register. Ew = Address of word-sized object in memory or register. Dw = Unsigned word. Dc = Signed byte (“character”), range: -128 to +127 (decimal). Db = Unsigned byte.
数字 x (0-3) 和 m (0-7) 根据以下方案对寻址模式进行编码。一个或多个字节(标记为:Disp)可能紧跟在 xrm 之后,如下所述。表 1:16 位寻址模式 (x, m):Eb = 内存或寄存器中字节大小对象的地址。Ew = 内存或寄存器中字大小对象的地址。Dw = 无符号字。Dc = 有符号字节(“字符”),范围:-128 到 +127(十进制)。Db = 无符号字节。
x m Disp Eb Ew ------------------ 3 r Rb Rw 0 6 Dw DS:[Dw] 0 m Base:[0] (except for xm = 06). 1 m Dc Base:[Dc] 2 m Dw Base:[Dw] x 0 Disp DS:[BX + SI + Disp] x 1 Disp DS:[BX + DI + Disp] x 2 Disp SS:[BP + SI + Disp] x 3 Disp SS:[BP + DI + Disp] x 4 Disp DS:[SI + Disp] x 5 Disp SS:[DI + Disp] x 6 Disp SS:[BP + Disp] (except for xm = 06) x 7 Disp DS:[BX + Disp].
x m Disp Eb Ew ------------------ 3 r Rb Rw 0 6 Dw DS:[Dw] 0 m Base:[0](xm = 06 除外)。1 m Dc Base:[Dc] 2 m Dw Base:[Dw] x 0 Disp DS:[BX + SI + Disp] x 1 Disp DS:[BX + DI + Disp] x 2 Disp SS:[BP + SI + Disp] x 3 Disp SS:[BP + DI + Disp] x 4 Disp DS:[SI + Disp] x 5 Disp SS:[DI + Disp] x 6 Disp SS:[BP + Disp](xm = 06 除外) x 7 Disp DS:[BX + Disp]。
This expands into the following table: TABLE 1a: 16-BIT ADDRESSING MODE (x, m) for the expansion impaired. :) xm Eb/Ew xm Eb/Ew xm Eb/Ew xm Eb/Ew 00 DS:[BX + SI] 10 Dc DS:[BX + SI + Dc] 20 Dw DS:[BX + SI + Dw] 30 AL/AX 01 DS:[BX + DI] 11 Dc DS:[BX + BI + Dc] 21 Dw DS:[BX + DI + Dw] 31 CL/CX 02 SS:[BX + SI] 12 Dc SS:[BP + SI + Dc] 22 Dw SS:[BP + SI + Dw] 32 DL/DX 03 SS:[BX + DI] 13 Dc SS:[BP + DI + Dc] 23 Dw SS:[BP + DI + Dw] 33 BL/BX 04 DS:[SI] 14 Dc DS:[SI + Dc] 24 Dw DS:[SI + Dw] 34 AH/SP 05 DS:[DI] 15 Dc DS:[DI + Dc] 25 Dw DS:[DI + Dw] 35 CH/BP 06 Dw DS:[Dw] 16 Dc SS:[BP + Dc] 26 Dw SS:[BP + Dw] 36 DH/SI 07 DS:[BX] 17 Dc DS:[BX + Dc] 27 Dw DS:[BX + Dw] 37 BH/DI.
这扩展为下表:表 1a:16 位寻址模式 (x, m),供扩展障碍者参考。:) xm Eb/Ew xm Eb/Ew xm Eb/Ew xm Eb/Ew 00 DS:[BX + SI] 10 Dc DS:[BX + SI + Dc] 20 Dw DS:[BX + SI + Dw] 30 AL/AX 01 DS:[BX + DI] 11 Dc DS:[BX + BI + Dc] 21 Dw DS:[BX + DI + Dw] 31 CL/CX 02 SS:[BX + SI] 12 Dc SS:[BP + SI + Dc] 22 Dw SS:[BP + SI + Dw] 32 DL/DX 03 SS:[BX + DI] 13 Dc SS:[BP + DI + Dc] 23 Dw SS:[BP + DI + Dw] 33 BL/BX 04 DS:[SI] 14 Dc DS:[SI + Dc] 24 Dw DS:[SI + Dw] 34 AH/SP 05 DS:[DI] 15 Dc DS:[DI + Dc] 25 Dw DS:[DI + Dw] 35 CH/BP 06 Dw DS:[Dw] 16 Dc SS:[BP + Dc] 26 Dw SS:[BP + Dw] 36 DH/SI 07 DS:[BX] 17 Dc DS:[BX + Dc] 27 Dw DS:[BX + Dw] 37 BH/DI。
Operands where x is 0, 1, or 2 are all pointers. If the instruction is a WORD instruction (211, 213, 214, 216 are), then this pointer addresses a word-sized object. The format of the object at the indicated address will always be low-order byte first, and high-order byte second. Otherwise the instruction is a BYTE instruction (210, 212) and the pointer addresses byte-sized object at the indicated address. The default segments (DS:, SS:) can be overridden with a segment prefix. In all cases it’s understood that everything has the default segment DS, except for the two stack/frame pointers (BP and SP) whose default segment is SS. That will be explained below.
x 为 0、1 或 2 的操作数均为指针。如果指令是字指令(211、213、214、216 是),则此指针寻址一个字大小的对象。指定地址处对象的格式始终是低位字节在前,高位字节在后。否则,该指令是字节指令(210、212),指针寻址指定地址处的字节大小对象。默认段(DS:、SS:)可以使用段前缀覆盖。在所有情况下,可以理解除两个栈/帧指针(BP 和 SP,其默认段为 SS)外,所有内容都具有默认段 DS。这将在下面解释。
Modes where x = 1, or 2 will require displacement bytes (Dc or Dw) to follow the opcode as explained above. When x = 3, WORD sized instructions address the word registers (AX, CX, …) and the BYTE size instructions the byte registers (AL, CL, …). EXAMPLE 1: The instruction opcode: 210 135 375. Here, xm = 15, and r = 3, so the operands are: mov Eb, Rb => mov byte ptr DS:[DI + Dc], BL. The displacement, Dc, is 375 (or fd in hexadecimal), which is the signed byte -3. So the instruction reads: mov byte ptr DS:[DI - 3], BL or just: mov [DI - 3], BL. In C-like notation, the meaning of this operation would be: ((byte *)DS) [DI - 3] = BL;
x = 1 或 2 的模式将需要位移字节(Dc 或 Dw)跟随操作码,如上所述。当 x = 3 时,字大小指令寻址字寄存器(AX, CX, …),字节大小指令寻址字节寄存器(AL, CL, …)。示例 1:指令操作码:210 135 375。此处,xm = 15,r = 3,因此操作数为:mov Eb, Rb => mov byte ptr DS:[DI + Dc], BL。位移 Dc 为 375(十六进制为 fd),即有符号字节 -3。因此指令读取为:mov byte ptr DS:[DI - 3], BL 或仅为:mov [DI - 3], BL。在类 C 符号中,此操作的含义为:((byte *)DS) [DI - 3] = BL;
EXAMPLE 2: The instruction opcode: 216 332. Here, xm = 32, and s = 3, so the operands are: mov SR, Ew => mov DS, DX. A move to CS is not possible (because the far jump instruction already does that) so that the
示例 2:指令操作码:216 332。此处,xm = 32,s = 3,因此操作数为:mov SR, Ew => mov DS, DX。移动到 CS 是不可能的(因为远跳转指令已经执行了该操作),因此