• Tidak ada hasil yang ditemukan

Introduction to x86 Assembly

N/A
N/A
Protected

Academic year: 2025

Membagikan "Introduction to x86 Assembly"

Copied!
38
0
0

Teks penuh

(1)

Introduction to x86 Assembly

Lecture 2

80x86 architecture, registers and basic assembly

(2)

Intel 8086 microprocessor

● released in 1978

● 16 bit

● the x86 family

https://en.wikipediB.org/wiki/Intel_8086

(3)

CPU, Memory, instructions and data

CPU

Machine Code

Main Memory

Data Bus

Address Bus Registers

(4)

CPU, Memory, instructions and data

CPU

Machine Code

Main Memory

Data Bus

Address Bus Registers

Data

(5)

Intel 8086 architecture

http://www.cosc.brocku.ca/~bockusd/3p92/Local_Pages/8086_achitecture.htm

(6)

Intel 8086 registers

● 16 bit registers

● 8 bit access

○ AX,BX,CX,DX

○ e.g. AX = (AH | AL)

http://bucarotechelp.com/computers/arch

(7)

Intel 8086 registers

http://bucarotechelp.com/computers/arch itecture/86011201.asp

AL AH

AX

8 bits 8 bits

(8)

Intel 8086 assembly syntax

http://bucarotechelp.com/computers/arch

(9)

Intel 8086 assembly commands

http://bucarotechelp.com/computers/arch itecture/86011201.asp

mov x,y xchg x,y inc x dec x add x,y sub x,y neg x

; bitwise operators and x,y

or x,y xor x,y not x

(10)

Intel 8086 assembly commands

http://bucarotechelp.com/computers/arch mov x,y

inc x dec x

add x,y ; x <- x+y sub x,y ; x <- x-y

; bitwise operators

and x,y ; x <- x & y or x,y ; x <- x | y xor x,y ; x <- x ^ y

x,y: register, constant, memory (address)

(11)

Intel 8086 assembly commands

http://bucarotechelp.com/computers/arch itecture/86011201.asp

assume u,v are memory locations (variables)

mov ax, bx mov ax, 1 mov al, ah mov cl, 123 mov ax, [u]

mov [v], bx

mov byte [v], 12

mov [v], [u]

(12)

Intel 8086 assembly commands

http://bucarotechelp.com/computers/arch assume u,v are memory locations (variables)

mov ax, bx mov ax, 1 mov al, ah mov cl, 123 mov ax, [u]

mov [v], bx

mov byte [v], 12

mov [v], [u]

(13)

Intel 8086 assembly commands

http://bucarotechelp.com/computers/arch itecture/86011201.asp

assume u,v are memory locations (variables)

mov ax, bx mov ax, 1 mov al, ah mov cl, 123 mov ax, [u]

mov [v], bx

mov byte [v], 12

mov [v], [u]

mov ax,[u]

mov [v], ax

(14)

Intel 8086 assembly commands

http://bucarotechelp.com/computers/arch assume u,v are memory locations (variables)

add ax, bx add ax, 1 add al, ah add cl, 123 add ax, [u]

add [v], bx

add byte [v], 12

add [v], [u]

(15)

Intel 8086 assembly commands

http://bucarotechelp.com/computers/arch itecture/86011201.asp

assume u,v are memory locations (variables)

add ax, bx add ax, 1 add al, ah add cl, 123 add ax, [u]

add [v], bx

add byte [v], 12

add [v], [u]

(16)

Intel 8086 assembly commands

http://bucarotechelp.com/computers/arch assume u,v are memory locations (variables)

add ax, bx add ax, 1 add al, ah add cl, 123 add ax, [u]

add [v], bx

add byte [v], 12

add [v], [u]

mov ax,[u]

add [v],ax

(17)

Intel 8086 assembly commands

http://bucarotechelp.com/computers/arch itecture/86011201.asp

; bx = (ax-10)*2

; ax = (ax+1)*8

; ax = (ax-1)*9

(18)

Intel 8086 assembly commands

http://bucarotechelp.com/computers/arch

; bx = (ax-10)*2 mov bx, ax sub bx, 10 add bx, bx

; ax = (ax+1)*8

; ax = (ax-1)*9

(19)

Intel 8086 assembly commands

http://bucarotechelp.com/computers/arch itecture/86011201.asp

; bx = (ax-10)*2 mov bx, ax sub bx, 10 add bx, bx

; ax = (ax+1)*8 inc ax

add ax,ax add ax,ax add ax,ax

; ax = (ax-1)*9

(20)

Intel 8086 assembly commands

http://bucarotechelp.com/computers/arch

; bx = (ax-10)*2 mov bx, ax sub bx, 10 add bx, bx

; ax = (ax+1)*8 inc ax

add ax,ax add ax,ax add ax,ax

; ax = (ax-1)*9 dec ax

mov si,ax add ax,ax add ax,ax add ax,ax

(21)

80386 (IA-32, i386) 8086, 80286

http://bucarotechelp.com/computers/arch itecture/86011201.asp

http://www.byclb.com/TR/Tutorials/

microprocessors/ch2_1.htm

(22)

80386 (IA-32, i386)

AL AH

AX

8 bits 8 bits

(23)

80386 (IA-32, i386)

AL AH

AX

8 bits 8 bits

EAX

16 bits

(24)

64 bit x86 systems (x86-64, x64, AMD64)

CPU

Machine Code

Main Memory

64-bit Data Bus

64-bit Address Bus 64-bit Registers

Data

(25)

x86-64 bit registers

AL AH

AX

8 bits 8 bits

EAX

16 bits

(26)

x86-64 bit registers

AL AH

AX

8 bits 8 bits

EAX

16 bits 32 bits

RAX

(27)

x86-64 bit registers

SP

8 bits 8 bits

ESP

16 bits

(28)

x86-64 bit registers

SP

8 bits 8 bits

ESP

16 bits 32 bits

RSP

(29)

x86-64 bit registers

SL

SP

8 bits 8 bits

ESP

16 bits 32 bits

RSP

(30)

x86-64 bit registers (x86-64, AMD64, Intel64, x64)

(31)

x86-64 registers

● RAX

● RCX

● RDX

● RBX

● RBP

● RSI

● RDI

● RSP

● R8

● R9

● R10

● R11

● R12

● R13

● R14

● R15

(32)

x86-64 registers

● RAX = R0

● RCX = R1

● RDX = R2

● RBX = R3

● RBP = R4

● RSI = R5

● RDI = R6

● RSP = R7

● R8

● R9

● R10

● R11

● R12

● R13

● R14

● R15

(33)

x86-64 bit registers

AL AH

AX

8 bits 8 bits

EAX

16 bits 32 bits

RAX

(34)

x86-64 bit registers

AL AH

AX

8 bits 8 bits

EAX

16 bits 32 bits

R0

(35)

x86-64 bit registers

AL AH

AX

8 bits 8 bits

R0d

16 bits 32 bits

R0

(36)

x86-64 bit registers

AL AH

R0w

8 bits 8 bits

R0d

16 bits 32 bits

R0

(37)

x86-64 bit registers

R0b AH

R0w

8 bits 8 bits

R0d

16 bits 32 bits

R0

(38)

x86-64 bit registers

R8b

R8w

8 bits 8 bits

R8d

16 bits 32 bits

R8

Referensi

Dokumen terkait

(ALU) Internal (ALU) Control Unit CPU I/O System Bus Floating CPU Intercon- nection Unit Memory us g Point Unit Registers 12022008 # 28 COA/Endro

Register lainnya yang digunakan sebagai jembatan antara CPU dengan main memory adalah memory address register (MAR) yang digunakan untuk menampung data atau

Programs and their Execution Program in memory : sequence of instructions known to CPU The processorCPU works as follows, Step A: pick next instruction in the sequence.. Step B: get

$”; Message to be displayed .CODE MAIN PROC mov ax,@data mov ds,ax mov ah,9h ; function to display a string mov dx,offset message ; offset of Message string int 21h ; Dos

 Address registers  For the temporary address calculations  Eg:- base register, index register  Arithmetic registers  for temporarily holding the operands and results of

Hardware Basics Output CPU Devices Input Devices Main Secondary Memory Memory Figure 1.1: Functional view of a computer include mobile computing, networking,

The general purpose registers are for manipulating or transferring data; the address registers contain memory addresses and are used to point to the locations in memory where data will

• PC Bus Architecture CPU North Bridge Main Memory LAN South Bridge AGP Bus Memory Bus PCI Bus SCSI Graphics Adaptor USB PCI Bus slots... • PCI Peripheral Component