CMU Computer Systems: Machine-Level Programming (Basic)

Basic

  • History of Intel processors and architectures
  • C, assembly, machine code
  • Assembly Basics: Registers, operands, move
  • Arithmetic & logical operations
Intel x86 Processors
  • Dominate laptop/desktop/server market
  • Evolutionary design
  • Complex instruction set computer (CISC)
Definitions
  • Architecture: The parts of a processor design that one needs to
    understand or write assembly/machine code
  • Microarchitecture: Implementation of the architecture
  • Code Forms: Machine Code, Assembly Code
Assembly/Machine Code View

在这里插入图片描述

Programmer-Visible State
 PC, Register file, Condition codes, Memory

Turning C into Object Code

 C program --Complier–> Asm program --Assembler–> Object program–Linker–> Executable program

Assembly Characteristics
  • Data Types
    • Integer
    • Floating point data of 4, 8, or 10 bytes
    • Code: Byte sequences encoding series of instructions
    • No aggregate types such as arrays or structures
  • Operations
    • Perform arithmetic function on register or memory data
    • Transfer data between memory and register
    • Transfer control
x86-64 Integer Registers

16 registers: hold integers and pointers
%r: 64 bit %e: 32bit
%rax %rcx %rdx %rbx %rsi %rdi %rsp %rbp
%r8-15

Moving Data
  • Moving Data
    • movq Source, Dest;
  • Operand Types
    • Immediate: Constant integer data
    • Register: One of 16 integer registers
    • Memory: 8 consecutive bytes of memory at address given by register
Simple Memory Addressing Modes
  • Normal (R)

    • Register R specifies memory address
    • movq (%rcx), %rax
  • Displacement

    • Register R specifies start of memory region
    • movq 8(%rbp), %rdx
Complete Memory Addressing Modes
  • Most General Form
    • D(Rb, Ri, S)
  • Special Cases
    • (Rb, Ri)
    • D(Rb, Ri)
    • (Rb, Ri, S)
Address Computation Instruction
  • leaq Src, Dst
    • Src is address mode expression
    • Set Dst to address denoted by expression
  • Uses
    • Computing addresses without a memory reference
    • Computing arithmetic expressions of the form x + k*y
Some Arithmetic Operations
  • Two Operand Instructions
  • One Operand Instructions
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值