DEC 0 1 2 3 4 5 6 7
HEX 0 1 2 3 4 5 6 7
BIN 0000 0001 0010 0011 0100 0101 0110 0111
DEC 8 9 10 11 12 13 14 15
HEX 8 9 A B C D E F
BIN 1000 1001 1010 1011 1100 1101 1110 1111

Machine-Level Representation of Programs

3.3 Data Formats 数据格式

Intel uses the term “word” to refer to a 16-bit data type .

Size of C data types in x86-64

C decalaration Intel data type Assembly-code suffix Size(bytes)
char byte b 1
short word w 2
int double word l 4
long quad word q 8
char * quad word q 8
float single precision s 4
double double precision l 8

3.4 Acssessing Information


64 register 意思 备注
%rax return value
%rbx callee saved
%rcx 4th argument
%rdx 3rd argument
%rsi 2nd argument
%rdi 1nd argument
%rbp callee saved
%rsp stack point
%r8 5th argument
%r9 6th argument
%r10 callee saved
%r11 callee saved
%r12 callee saved
%r13 callee saved
%r14 callee saved
%r15 callee saved

3.5 Arithmetic and Logical Operations

3.5.1 Load Effective Address

3.6 Control

3.6.1 Condition Codes

3.6.4 Jump Instruction Encodings

For the most part, we will not concern ourselves with the detailed format of machine code.


On the other hand, understanding how the targets of jump instructions are encoded will become important when we study linking in Chapter 7.


In addition, it helps when interpreting the output of a disassembler.


In assembly code, jump targets are written using symbolic labels.


The assembler, and later the linker, generate the proper encodings of the jump targets.


There are several different encodings for jumps, but some of the most commonly used ones are PC relative.


PC = program counter


That is, they encode the difference between the address of the target instruction and the address of the instruction immediately following the jump.


These offsets can be encoded using 1, 2, or 4 bytes.

偏移量可以编码为1、2、4 byte

A second encoding method is to give an “absolute” address, using 4 bytes to directly specify the target.


The assembler and linker select the appropriate encodings of the jump destinations.