diff options
| author | Cliff Click <cliffc@acm.org> | 2026-10-07 09:53:15 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-10-07 09:53:15 -0700 |
| commit | b2862f980f3d78012066ef1cc09d4ad58f886c0f (patch) | |
| tree | bbeab7de6ac8b556911d117989ab4bbc0324ecb5 /chapter21 | |
| parent | 863a6ed0ad723e06c76f392d4fb3a5f6bd22863c (diff) | |
| download | Simple-pr262-doc-followups.tar.gz Simple-pr262-doc-followups.zip | |
Pick up japanese transaltionpr262-doc-followups
A bunch of minor README fixes, missing TOC, grammer cleanup
Diffstat (limited to 'chapter21')
| -rw-r--r-- | chapter21/README.ja.md | 2 | ||||
| -rw-r--r-- | chapter21/README.md | 2 | ||||
| -rw-r--r-- | chapter21/docs/18-grammar.ja.md | 138 | ||||
| -rw-r--r-- | chapter21/docs/18-grammar.md | 132 | ||||
| -rw-r--r-- | chapter21/docs/21-grammar.ja.md | 141 | ||||
| -rw-r--r-- | chapter21/docs/21-grammar.md | 141 | ||||
| -rw-r--r-- | chapter21/docs/encoding-reference.ja.md | 17 | ||||
| -rw-r--r-- | chapter21/docs/encoding-reference.md | 52 |
8 files changed, 323 insertions, 302 deletions
diff --git a/chapter21/README.ja.md b/chapter21/README.ja.md index dbf11374..95ffbcf8 100644 --- a/chapter21/README.ja.md +++ b/chapter21/README.ja.md @@ -11,6 +11,8 @@ 直線的なリビジョン履歴で [この章](https://github.com/SeaOfNodes/Simple/tree/linear-chapter21) を読み、[第20章と比較](https://github.com/SeaOfNodes/Simple/compare/linear-chapter20...linear-chapter21) することもできます。 +この章の[完全な言語文法](docs/21-grammar.ja.md)はこちらです。 + ## マシンノードからバイトへ 命令選択は演算とレジスタ制約を選びます。レジスタ割り当ては物理レジスタとスタックスロットを割り当てます。その後、エンコーディングがオペコード、割り当て済みレジスタ、即値オペランドを命令バイトへ組み合わせます。この時点で命令は別のレジスタを選べません。周囲の命令が、すでに割り当て器の選択に依存しているためです。 diff --git a/chapter21/README.md b/chapter21/README.md index 57705fa7..b8d065ff 100644 --- a/chapter21/README.md +++ b/chapter21/README.md @@ -15,6 +15,8 @@ You can also read [this chapter](https://github.com/SeaOfNodes/Simple/tree/linea in the linear revision history and [compare it to Chapter 20](https://github.com/SeaOfNodes/Simple/compare/linear-chapter20...linear-chapter21). +Here is the [complete language grammar](docs/21-grammar.md) for this chapter. + ## From machine nodes to bytes Instruction selection chooses the operation and register constraints. Register diff --git a/chapter21/docs/18-grammar.ja.md b/chapter21/docs/18-grammar.ja.md deleted file mode 100644 index dbd7f0fd..00000000 --- a/chapter21/docs/18-grammar.ja.md +++ /dev/null @@ -1,138 +0,0 @@ -# 第21章の文法 - -[English](18-grammar.md) | 日本語 - -この文書は [原文](18-grammar.md) の日本語訳です。 - -> 訳注: 原文の見出しは「Grammar for Chapter 16」です。この日本語版では、配置されている第21章に合わせた見出しにしています。 - -[第21章に戻る](../README.ja.md) - -```antlrv4 -grammar SimpleLanguage; - -program : block EOF ; - -block : statement+ ; - - -statement - : '{' block '}' - | returnStatement - | ifStatement - | whileStatement - | breakStatement - | continueStatement - | structDeclaration - | expressionStatement - ; - - -returnStatement : 'return' expression ';' ; - -ifStatement : 'if' '(' expression ')' statement ('else' statement)? ; - -whileStatement : 'while' '(' expression ')' statement ; - -breakStatement : 'break' ';' ; - -continueStatement : 'continue' ';' ; - - -structDeclaration : 'struct' IDENTIFIER '{' block '}' ; - -expressionStatement - : type IDENTIFIER ';' - | type IDENTIFIER '=' expression ';' - | IDENTIFIER '=' expression ';' - | expression - ; - -PRIMTYPE - : 'int' - | 'i8' - | 'i16' - | 'i32' - | 'i64' - | 'u8' - | 'u16' - | 'u32' - | 'flt' - | 'f32' - | 'f64' - | 'bool' - ; - -type - : PRIMTYPE - | typeName '?'? - | typeName nestedArray+ - ; - -nestedArray : '?'? '[]'* ; - -typeName : IDENTIFIER ; - - -expression : bitWiseExpression ; - -bitWiseExpression - : comparisonExpression ( '&' | '|' | '^' ) comparisonExpression)* - ; - -comparisonExpression - : shiftExpression (('==' | '!='| '>'| '<'| '>='| '<=') shiftExpression)* - ; - -shiftExpression - : additiveExpression ( '<<' | '>>>' | '>>' ) additiveExpression)* - ; - -additiveExpression - : multiplicativeExpression (('+' | '-') multiplicativeExpression)* - ; - -multiplicativeExpression - : unaryExpression (('*' | '/') unaryExpression)* - ; - -unaryExpression - : ('-') unaryExpression - | '!' unaryExpression - | primaryExpression postAssign - ; - -primaryExpression - : INTEGER_LITERAL - | FLOAT_LITERAL - | '(' expression ')' - | 'true' - | 'false' - | 'null' - | newExpression - | IDENTIFIER - ; - -newExpression - : 'new' IDENTIFIER [ '{' block '}' ] - | 'new' IDENTIFIER '[' expression ']' - ; - -postAssign : postFix [ '=' expression ] | [ '#' ]; - -postFix - : '.' IDENTIFIER postFix - | '[' expression ']' postFix - ; - - -IDENTIFIER : NON_DIGIT (NON_DIGIT | DIGIT)* ; - -INTEGER_LITERAL - : [1-9]DIGIT* - | [0] - ; - -NON_DIGIT: [a-zA-Z_]; -DIGIT: [0-9]; -``` diff --git a/chapter21/docs/18-grammar.md b/chapter21/docs/18-grammar.md deleted file mode 100644 index 51539d0b..00000000 --- a/chapter21/docs/18-grammar.md +++ /dev/null @@ -1,132 +0,0 @@ -# Grammar for Chapter 16 - -English | [日本語](18-grammar.ja.md) - -```antlrv4 -grammar SimpleLanguage; - -program : block EOF ; - -block : statement+ ; - - -statement - : '{' block '}' - | returnStatement - | ifStatement - | whileStatement - | breakStatement - | continueStatement - | structDeclaration - | expressionStatement - ; - - -returnStatement : 'return' expression ';' ; - -ifStatement : 'if' '(' expression ')' statement ('else' statement)? ; - -whileStatement : 'while' '(' expression ')' statement ; - -breakStatement : 'break' ';' ; - -continueStatement : 'continue' ';' ; - - -structDeclaration : 'struct' IDENTIFIER '{' block '}' ; - -expressionStatement - : type IDENTIFIER ';' - | type IDENTIFIER '=' expression ';' - | IDENTIFIER '=' expression ';' - | expression - ; - -PRIMTYPE - : 'int' - | 'i8' - | 'i16' - | 'i32' - | 'i64' - | 'u8' - | 'u16' - | 'u32' - | 'flt' - | 'f32' - | 'f64' - | 'bool' - ; - -type - : PRIMTYPE - | typeName '?'? - | typeName nestedArray+ - ; - -nestedArray : '?'? '[]'* ; - -typeName : IDENTIFIER ; - - -expression : bitWiseExpression ; - -bitWiseExpression - : comparisonExpression ( '&' | '|' | '^' ) comparisonExpression)* - ; - -comparisonExpression - : shiftExpression (('==' | '!='| '>'| '<'| '>='| '<=') shiftExpression)* - ; - -shiftExpression - : additiveExpression ( '<<' | '>>>' | '>>' ) additiveExpression)* - ; - -additiveExpression - : multiplicativeExpression (('+' | '-') multiplicativeExpression)* - ; - -multiplicativeExpression - : unaryExpression (('*' | '/') unaryExpression)* - ; - -unaryExpression - : ('-') unaryExpression - | '!' unaryExpression - | primaryExpression postAssign - ; - -primaryExpression - : INTEGER_LITERAL - | FLOAT_LITERAL - | '(' expression ')' - | 'true' - | 'false' - | 'null' - | newExpression - | IDENTIFIER - ; - -newExpression - : 'new' IDENTIFIER [ '{' block '}' ] - | 'new' IDENTIFIER '[' expression ']' - ; - -postAssign : postFix [ '=' expression ] | [ '#' ]; - -postFix - : '.' IDENTIFIER postFix - | '[' expression ']' postFix - ; - - -IDENTIFIER : NON_DIGIT (NON_DIGIT | DIGIT)* ; - -INTEGER_LITERAL - : [1-9]DIGIT* - | [0] - ; - -NON_DIGIT: [a-zA-Z_]; -DIGIT: [0-9]; -``` diff --git a/chapter21/docs/21-grammar.ja.md b/chapter21/docs/21-grammar.ja.md new file mode 100644 index 00000000..8cb8f27b --- /dev/null +++ b/chapter21/docs/21-grammar.ja.md @@ -0,0 +1,141 @@ +# 第21章の文法 + +[English](21-grammar.md) | 日本語 + +```antlrv4 +grammar SimpleLanguage; + +// Name lookup, assignable operands, type compatibility, and access permissions +// are checked by the compiler in addition to these syntax rules. +program : statement* EOF ; + +block : '{' statement* '}' ; + +statement + : block + | returnStatement + | ifStatement + | whileStatement + | forStatement + | breakStatement + | continueStatement + | structDeclaration + | declaration ';' + | assignment ';' + | ';' + ; + +returnStatement : 'return' assignment ';' ; +ifStatement : 'if' '(' assignment ')' statement ('else' statement)? ; +whileStatement : 'while' '(' assignment ')' statement ; +breakStatement : 'break' ';' ; +continueStatement : 'continue' ';' ; + +forStatement + : 'for' '(' (declaration | assignment)? ';' assignment? ';' assignment? ')' statement + ; + +structDeclaration : 'struct' IDENTIFIER block ';' ; + +declaration : declarationType binding (',' binding)* ; +declarationType : type | 'var' | 'val' ; +binding : bindingModifier? IDENTIFIER ('=' initializer)? ; +bindingModifier : '!' | '~' ; +initializer : assignment ; + +// The prefix qualifies the named struct reference, not an enclosing array. +// Each [] / [~] suffix qualifies its own array layer. ? requires a reference. +type + : functionType + | primitiveType typeSuffix* + | accessModifier? typeName typeSuffix* + ; +accessModifier : '!' | '~' ; +typeSuffix : '?' | '[]' | '[~]' ; +typeName : IDENTIFIER ; + +primitiveType + : 'int' | 'i8' | 'i16' | 'i32' | 'i64' + | 'u1' | 'u8' | 'u16' | 'u32' | 'byte' | 'bool' + | 'flt' | 'f32' | 'f64' + ; + +assignment : expression (assignmentOperator assignment)? ; +assignmentOperator + : '=' | '+=' | '-=' | '*=' | '/=' | '&=' | '|=' | '^=' + | '<<=' | '>>=' | '>>>=' + ; + +expression : bitwiseExpression ('?' assignment (':' assignment)?)? ; + +bitwiseExpression + : comparisonExpression (('&' | '|' | '^') comparisonExpression)* + ; + +comparisonExpression + : shiftExpression (('==' | '!=' | '<' | '<=' | '>' | '>=') shiftExpression)* + ; + +shiftExpression + : additiveExpression (('<<' | '>>' | '>>>') additiveExpression)* + ; + +additiveExpression + : multiplicativeExpression (('+' | '-') multiplicativeExpression)* + ; + +multiplicativeExpression + : unaryExpression (('*' | '/') unaryExpression)* + ; + +unaryExpression + : ('-' | '!') unaryExpression + | updateOperator IDENTIFIER + | postfixExpression + ; + +// Prefix updates require a local name; postfix updates also allow fields +// and array elements. All updates require an assignable operand. +updateOperator : '++' | '--' ; +postfixExpression : primaryExpression postfixSuffix* updateOperator? ; +postfixSuffix : '.' IDENTIFIER | '[' assignment ']' | '#' | callSuffix ; + +primaryExpression + : INTEGER_LITERAL + | FLOAT_LITERAL + | 'true' + | 'false' + | 'null' + | IDENTIFIER + | '(' assignment ')' + | newExpression + | functionExpression + ; + +// A function is an expression bound with an ordinary declaration. +// Its last statement supplies the implicit result; return can exit earlier. +functionExpression : '{' parameterList? '->' statement* '}' ; +parameterList : (parameter ','?)+ ; +parameter : type bindingModifier? IDENTIFIER ; + +// Function types have unnamed, space-separated argument types. +// {int} is the zero-argument type; its function expression still uses ->. +functionType + : '{' type+ '->' type '}' '?'? + | '{' type '}' '?'? + ; + +callSuffix : '(' argumentList? ')' ; +argumentList : assignment (',' assignment)* ','? ; + +// Struct initialization uses a block; array allocation supplies a length. +newExpression : 'new' type ('[' assignment ']' | block)? ; + +INTEGER_LITERAL : '0' | [1-9] DIGIT* ; +FLOAT_LITERAL : DIGIT+ ('.' DIGIT* ('e' DIGIT+)? | 'e' '-'? DIGIT+) ; +IDENTIFIER : NON_DIGIT (NON_DIGIT | DIGIT)* ; +fragment NON_DIGIT : [a-zA-Z_] ; +fragment DIGIT : [0-9] ; +WHITESPACE : [ \t\r\n]+ -> skip ; +LINE_COMMENT : '//' ~[\r\n]* -> skip ; +``` diff --git a/chapter21/docs/21-grammar.md b/chapter21/docs/21-grammar.md new file mode 100644 index 00000000..111957a1 --- /dev/null +++ b/chapter21/docs/21-grammar.md @@ -0,0 +1,141 @@ +# Grammar for Chapter 21 + +English | [日本語](21-grammar.ja.md) + +```antlrv4 +grammar SimpleLanguage; + +// Name lookup, assignable operands, type compatibility, and access permissions +// are checked by the compiler in addition to these syntax rules. +program : statement* EOF ; + +block : '{' statement* '}' ; + +statement + : block + | returnStatement + | ifStatement + | whileStatement + | forStatement + | breakStatement + | continueStatement + | structDeclaration + | declaration ';' + | assignment ';' + | ';' + ; + +returnStatement : 'return' assignment ';' ; +ifStatement : 'if' '(' assignment ')' statement ('else' statement)? ; +whileStatement : 'while' '(' assignment ')' statement ; +breakStatement : 'break' ';' ; +continueStatement : 'continue' ';' ; + +forStatement + : 'for' '(' (declaration | assignment)? ';' assignment? ';' assignment? ')' statement + ; + +structDeclaration : 'struct' IDENTIFIER block ';' ; + +declaration : declarationType binding (',' binding)* ; +declarationType : type | 'var' | 'val' ; +binding : bindingModifier? IDENTIFIER ('=' initializer)? ; +bindingModifier : '!' | '~' ; +initializer : assignment ; + +// The prefix qualifies the named struct reference, not an enclosing array. +// Each [] / [~] suffix qualifies its own array layer. ? requires a reference. +type + : functionType + | primitiveType typeSuffix* + | accessModifier? typeName typeSuffix* + ; +accessModifier : '!' | '~' ; +typeSuffix : '?' | '[]' | '[~]' ; +typeName : IDENTIFIER ; + +primitiveType + : 'int' | 'i8' | 'i16' | 'i32' | 'i64' + | 'u1' | 'u8' | 'u16' | 'u32' | 'byte' | 'bool' + | 'flt' | 'f32' | 'f64' + ; + +assignment : expression (assignmentOperator assignment)? ; +assignmentOperator + : '=' | '+=' | '-=' | '*=' | '/=' | '&=' | '|=' | '^=' + | '<<=' | '>>=' | '>>>=' + ; + +expression : bitwiseExpression ('?' assignment (':' assignment)?)? ; + +bitwiseExpression + : comparisonExpression (('&' | '|' | '^') comparisonExpression)* + ; + +comparisonExpression + : shiftExpression (('==' | '!=' | '<' | '<=' | '>' | '>=') shiftExpression)* + ; + +shiftExpression + : additiveExpression (('<<' | '>>' | '>>>') additiveExpression)* + ; + +additiveExpression + : multiplicativeExpression (('+' | '-') multiplicativeExpression)* + ; + +multiplicativeExpression + : unaryExpression (('*' | '/') unaryExpression)* + ; + +unaryExpression + : ('-' | '!') unaryExpression + | updateOperator IDENTIFIER + | postfixExpression + ; + +// Prefix updates require a local name; postfix updates also allow fields +// and array elements. All updates require an assignable operand. +updateOperator : '++' | '--' ; +postfixExpression : primaryExpression postfixSuffix* updateOperator? ; +postfixSuffix : '.' IDENTIFIER | '[' assignment ']' | '#' | callSuffix ; + +primaryExpression + : INTEGER_LITERAL + | FLOAT_LITERAL + | 'true' + | 'false' + | 'null' + | IDENTIFIER + | '(' assignment ')' + | newExpression + | functionExpression + ; + +// A function is an expression bound with an ordinary declaration. +// Its last statement supplies the implicit result; return can exit earlier. +functionExpression : '{' parameterList? '->' statement* '}' ; +parameterList : (parameter ','?)+ ; +parameter : type bindingModifier? IDENTIFIER ; + +// Function types have unnamed, space-separated argument types. +// {int} is the zero-argument type; its function expression still uses ->. +functionType + : '{' type+ '->' type '}' '?'? + | '{' type '}' '?'? + ; + +callSuffix : '(' argumentList? ')' ; +argumentList : assignment (',' assignment)* ','? ; + +// Struct initialization uses a block; array allocation supplies a length. +newExpression : 'new' type ('[' assignment ']' | block)? ; + +INTEGER_LITERAL : '0' | [1-9] DIGIT* ; +FLOAT_LITERAL : DIGIT+ ('.' DIGIT* ('e' DIGIT+)? | 'e' '-'? DIGIT+) ; +IDENTIFIER : NON_DIGIT (NON_DIGIT | DIGIT)* ; +fragment NON_DIGIT : [a-zA-Z_] ; +fragment DIGIT : [0-9] ; +WHITESPACE : [ \t\r\n]+ -> skip ; +LINE_COMMENT : '//' ~[\r\n]* -> skip ; +``` diff --git a/chapter21/docs/encoding-reference.ja.md b/chapter21/docs/encoding-reference.ja.md index 8ccdc728..d04fc469 100644 --- a/chapter21/docs/encoding-reference.ja.md +++ b/chapter21/docs/encoding-reference.ja.md @@ -40,9 +40,6 @@ - [条件フラグ](#条件フラグ-1) 7. [再配置](#再配置) -> 訳注:原文の目次には本文に対応する節がない項目や、別の節を指すリンクがあります。 -> 日本語版の目次は本文の見出しに合わせています。本文の技術的な説明とコード例は原文に沿っています。 - この章では命令エンコーディングを追加します。命令エンコーディングとは、 プロセッサの命令セットアーキテクチャ(ISA)が定義する特定のバイナリ形式で機械命令を表すことです。 @@ -429,7 +426,7 @@ Arm は次の間接参照形式をサポートします。 [ストア](https://docsmirror.github.io/A64/2023-06/strb_imm.html):`str dst, [base + #offset]` -オフセットが定数でなければ……(訳注:原文のこの文は途中で途切れています)。 +オフセットがレジスタの場合は、即値オフセット形式ではなくレジスタオフセット形式を使います。 #### 分岐 @@ -465,7 +462,7 @@ Arm は次の間接参照形式をサポートします。 それ以外の場合は無視されます。 Simple では、REX プレフィックスをビットストリームの先頭に追加するだけです -(SEE の浮動小数点命令を除く。訳注:「SEE」は原文の表記です)。配置は次のとおりです。 +(SSE の浮動小数点命令を除く)。配置は次のとおりです。 | **フィールド** | **長さ** | **説明** | |:---------:|:----------:|---------------------------------------------------------------------------------| @@ -528,12 +525,14 @@ public enum MOD { ##### reg -reg フィールドは3ビットのフィールドで、15種類のレジスタをエンコードできます。 -(訳注:ビット数とレジスタ数について、ここでは原文の記述を保持しています。) +reg フィールドは3ビットで、8個のレジスタから1個を選びます。レジスタを指定する場合、 +REX.R によって4ビットに拡張され、16個のレジスタから1個を選べます。 ##### r/m -rm フィールドは直接または間接のレジスタオペランドを指定し、15種類のレジスタをエンコードできます。 +r/m フィールドは3ビットです。レジスタ直接指定モードでは、REX.B によって拡張され、 +16個のレジスタから1個を選べます。メモリ指定モードでは、アドレッシング形式または +ベースレジスタを選びます。一部の値は SIB バイトや RIP 相対アドレッシングを指定します。 ```java public static int modrm(MOD mod, int reg, int m_r) { @@ -625,7 +624,7 @@ X86-64 は複数の間接アドレッシングモードをサポートしますã #### 浮動小数点数 浮動小数点演算には、XMM レジスタまたはメモリにあるスカラーの単精度浮動小数点値を操作する -`SEE SIMD` 命令を使います(訳注:命令名の表記は原文どおりです)。 +`SSE SIMD` 命令を使います。 *注*:ALU 演算で XMM レジスタを使う場合、エンコーディングは非常に似ていますが、 レジスタ番号から `XMM_OFFSET` を引く必要がある点が異なります。 レジスタを連続した番号で数えているため、XMM レジスタに対応する GPR のペアを得るには、 diff --git a/chapter21/docs/encoding-reference.md b/chapter21/docs/encoding-reference.md index 5853b380..187a965e 100644 --- a/chapter21/docs/encoding-reference.md +++ b/chapter21/docs/encoding-reference.md @@ -13,37 +13,39 @@ See the [chapter overview](../README.md) for the compiler pipeline and experimen 4. [RISCV](#riscv) - [Instruction formats](#instruction-formats) - [Float](#float) - - [Indirect](#indirectmemop-2) + - [Indirect](#indirectmemop) - [Branch](#branch) - - [Function Constant](#function-constant) - - [LUI](#lui) - - [Large constants](#large-constants) + - [Immediates](#immediates) + - [Float Constants](#float-constants) + - [Int Constants](#int-constants) + - [Function Constants](#function-constants) 5. [ARM](#arm) - [Reg-form](#reg-form) - [Shift immediates](#shift-immediates) - - [asri](#asrimmediate) - - [LSL(immediate)](#lslimmediate) - - [LSR(immediate)](#lsrimmediate) - - [Logical Immediates](#logical-immediates) - - [Float](#float) + - [Float](#float-1) + - [Large constants](#large-constants) - [Function constant](#function-constant) - - [Immediate](#immediate) - [Conditional flags](#conditional-flags) - [Indirect](#indirectmemop-1) - - [Branching](#branching-) - - [Rip relative](#rip-relative) - - [Compare](#compare) -6. [AMD64](#amd64) + - [Branching](#branching) +6. [AMD64 X86-64](#amd64-x86-64) - [REX PREFIX](#rex-prefix) - - [Large constants](#large-constants) + - [Opcode](#opcode) - [MODR/M](#modrm) - [SIB](#sib) - [Displacement](#displacement) - [Immediate](#immediate) - - [Float](#float) - - [Indirect](#indirectmemop) - - [Conditional flags](#conditional-flags) + - [Indirect](#indirectmemop-2) + - [Float](#float-2) + - [Large constants](#large-constants-1) + - [Function constant](#function-constant-1) + - [Conditional flags](#conditional-flags-1) +7. [Relocation](#relocation) + - [Local Relocation](#local-relocation) + - [Global Relocation](#global-relocation) + - [Getting Relocations to All Agree](#getting-relocations-to-all-agree) + - [Large Constants](#large-constants-2) This chapter will add instruction encodings. Instruction encoding refers to @@ -433,7 +435,8 @@ Arm supports the following indirect forms: [Store](https://docsmirror.github.io/A64/2023-06/strb_imm.html): `str dst, [base + #offset]` -If the offset is not a con +For a register offset, use the register-offset form rather than the immediate-offset form. + #### Branching `B.cond` - branch [conditionally](https://developer.arm.com/documentation/dui0802/b/A32-and-T32-Instructions/Condition-codes?lang=en) to a label at a PC-relative offset. @@ -468,7 +471,7 @@ A *REX* prefix must not be encoded when: the `SSE` prefix. In all other cases, it is ignored. In Simple, the REX prefix is just appended to the beginning of the bit stream -(except SEE float instructions). The layout is the following: +(except SSE float instructions). The layout is the following: | **Field** | **Length** | **Description** | |:---------:|:----------:|---------------------------------------------------------------------------------| @@ -532,11 +535,14 @@ public enum MOD { ``` ##### reg -The reg field is a 3 bit field capable of encoding 15 different registers. +The reg field has 3 bits, selecting one of 8 registers. When it names a +register, REX.R extends it to 4 bits, selecting one of 16 registers. ##### r/m -The rm field specifies a direct or indirect register operand and is capable of encoding 15 different registers. +The r/m field has 3 bits. In register-direct mode, REX.B extends it to +select one of 16 registers. In memory modes, r/m selects the addressing form +or base register; some values select a SIB byte or RIP-relative addressing. ```java @@ -624,7 +630,7 @@ X86-64 support multiple indirect addressing modes: #### Float -For float operations we use `SEE SIMD` instructions that operate on scalar single precision floating0-point values located in the +For float operations we use `SSE SIMD` instructions that operate on scalar single precision floating-point values located in the XMM registers or memory. *Note*: When using XMM registers for ALU operations, the encoding is really similar with the exception that we need to subtract the `XMM_OFFSET` from the register number. |
