SlideShare a Scribd company logo
Assembly Syntax
[label] MNEMONIC [OPERANDS] [;comment]
Assembly Syntax
[label] MNEMONIC [OPERANDS] [;comment]
Does something...
Assembly Syntax
[label] MNEMONIC [OPERANDS] [;comment]
Does something... with the operand[s]
Assembly Syntax
[label] MNEMONIC [OPERANDS] [;comment]
MOV A, 100H
Eg.
Assembly Syntax
[label] MNEMONIC [OPERANDS] [;comment]
MOV A, 100H
Eg.
Move 100H into A
Assembly Syntax
[label] MNEMONIC [OPERANDS] [;comment]
MOV A, 100H
Eg.
Move 100H into A
“bites Tom dog”
Assembly Syntax
[label] MNEMONIC [OPERANDS] [;comment]
MOV A, 100H
Eg.
dest, source
Assembly Syntax
MNEMONIC [OPERANDS] [;comment]
Assembly Syntax
MNEMONIC [OPERANDS] [;comment]
MOV A, 100H ; load 100H into A
Eg.
Assembly Syntax
[label] MNEMONIC [OPERANDS] [;comment]
MOV A, 100H ; load 100H into A
cool
Address at which
code is stored
[label] MNEMONIC [OPERANDS] [;comment]
; Simple example
; Writes Hello World to the output
JMP start
hello: DB "Hello World!" ; Variable
DB 0 ; String terminator
start:
MOV C, hello ; Point to var
MOV D, 232 ; Point to output
CALL print
HLT ; Stop execution
print: ; print(C:*from, D:*to)
PUSH A
PUSH B
MOV B, 0
.loop:
MOV A, [C] ; Get char from var
MOV [D], A ; Write to output
INC C
INC D
CMP B, [C] ; Check if end
JNZ .loop ; jump if not
POP B
POP A
RET
Assembler
directives
Assembly Simulator
https://schweigi.github.io/assembler-simulator/
x86 Mnemonics
MOV b,a move a b ; a unchanged
ADD b,a add a+b b; a unchanged
SUB b,a subtract a-b b; a unchanged
AND b,a and a AND b b bitwise; a unchanged
OR b,a or a OR b b bitwise; a unchanged
CMP b,a compare set flags as if b-a; a,b unchanged
INC rm increment rm + 1 rm
DEC rm decrement rm - 1 rm
NOT rm not 1’s complement of rm rm
NEG rm negate negative (2’s complement) of rm rm
b,a: any of m,r r,m r,r m,imm r,imm
rm: register or memory, via various addressing modes
The Art of Electronics p.994
Mnemonic Operand(s) English What it does:
x86 Mnemonics
Immediate: A value. eg. 200, 0xA4, 101b
Register: Built-in registers within the microchip.
Memory: Random Access Memory (RAM) space.
https://www.tutorialspoint.com/assembly_programming/assembly_registers.htm
General-Purpose Registers
AX
DX
CX
BX
BP
SI
DI
SP
0
15
The Art of Electronics p.994
LSB
MSB
General-Purpose Registers
AX
DX
CX
BX
BP
SI
DI
SP
0
15
Stack pointer
Destination index
Source index
Base pointer
Loop, shift, count
MUL/DIV/I/0
MUL/DIV/I/0
The Art of Electronics p.994
LSB
MSB
Base register
General-Purpose Registers
AX
DX
CX
BX
BP
SI
DI
SP
0
15
Stack pointer
Destination index
Source index
Base pointer
Loop, shift, count
MUL/DIV/I/0
MUL/DIV/I/0
The Art of Electronics p.994
LSB
MSB
Base register
Addressing Modes
DIRECT: MOV A, 100H; moves value of 100H into register A
Memory Addressing Modes
The Art of Electronics p.994
MOV B, 10; put “address” 10 in B
Memory Addressing Modes
The Art of Electronics p.994
INDIRECT:
MOV B, 10; put “address” 10 in B
MOV [B], 28; store 28 at “address” 10
Memory Addressing Modes
A vs. [A]
Register A Contents of
Register A
A 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1
BX,BP,SI,DI
Memory Addressing Modes
The Art of Electronics p.994
.data
my_var DW 0abcdh ; my_var = 0xabcd
.code
MOV A, [my_var] ; copy my_var content into A (ax=0xabcd)
Memory Addressing Modes
The Art of Electronics p.994
byte_table DB 12, 15, 16, 22 ; table of bytes
MOV A, [byte_table + 2]
INDEXED:
x86 Stack
PUSH rm push push rm onto stack (2 bytes)
POP rm pop pop 2 bytes from stack to rm
The Art of Electronics p.994
Stack
Wikipedia
x86 Control
JMP label jump jump to instr label
Jcc label jump cond jump to instr label if cc true
CALL label call push next adr, jump to instr label
RET return pop stack, jump to that adr
IRET return fr int pop stack, restore flags, return
STI set int enable interrupts
CLI clear int enable interrupts
label: via various addressing modes
cc: any of Z NZ G GE LE L C NC S NS
The Art of Electronics p.994
The Art of Electronics p.994
The Art of Electronics p.994
x86 Input/Output
IN AX, port input port AX(or AL)
OUT port, AX output AX(or AL) port
port: byte(via imm) or word (via DX)
The Art of Electronics p.994

More Related Content

What's hot

BBS crawler for Taiwan
BBS crawler for TaiwanBBS crawler for Taiwan
BBS crawler for Taiwan
Buganini Chiu
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
9840596838
 
Flow Network Talk
Flow Network TalkFlow Network Talk
Flow Network Talk
Imane Haf
 

What's hot (20)

Regexp
RegexpRegexp
Regexp
 
8086 instruction set
8086  instruction set8086  instruction set
8086 instruction set
 
Assembly language (addition and subtraction)
Assembly language (addition and subtraction)Assembly language (addition and subtraction)
Assembly language (addition and subtraction)
 
BBS crawler for Taiwan
BBS crawler for TaiwanBBS crawler for Taiwan
BBS crawler for Taiwan
 
Memory efficient pytorch
Memory efficient pytorchMemory efficient pytorch
Memory efficient pytorch
 
instruction set of 8086
instruction set of 8086instruction set of 8086
instruction set of 8086
 
Lec06
Lec06Lec06
Lec06
 
C++ AMP 실천 및 적용 전략
C++ AMP 실천 및 적용 전략 C++ AMP 실천 및 적용 전략
C++ AMP 실천 및 적용 전략
 
5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron)
 
Docopt
DocoptDocopt
Docopt
 
Code GPU with CUDA - Memory Subsystem
Code GPU with CUDA - Memory SubsystemCode GPU with CUDA - Memory Subsystem
Code GPU with CUDA - Memory Subsystem
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Max Flow Problem
Max Flow ProblemMax Flow Problem
Max Flow Problem
 
Up 8086 q9
Up 8086 q9Up 8086 q9
Up 8086 q9
 
Code GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersCode GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limiters
 
3 rd animation
3 rd animation3 rd animation
3 rd animation
 
Introduction to nand2 tetris
Introduction to nand2 tetrisIntroduction to nand2 tetris
Introduction to nand2 tetris
 
Instruction Set Of 8086 DIU CSE
Instruction Set Of 8086 DIU CSEInstruction Set Of 8086 DIU CSE
Instruction Set Of 8086 DIU CSE
 
Flow Network Talk
Flow Network TalkFlow Network Talk
Flow Network Talk
 
Introduction to go
Introduction to goIntroduction to go
Introduction to go
 

Similar to Assembly class

EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
PRADEEP
 
Home works summary.pptx
Home works summary.pptxHome works summary.pptx
Home works summary.pptx
HebaEng
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
jemimajerome
 
Programming basic computer
Programming basic computerProgramming basic computer
Programming basic computer
Martial Kouadio
 

Similar to Assembly class (20)

Virtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsVirtual Machine for Regular Expressions
Virtual Machine for Regular Expressions
 
[ASM]Lab4
[ASM]Lab4[ASM]Lab4
[ASM]Lab4
 
Assembly language part I
Assembly language part IAssembly language part I
Assembly language part I
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 
Microprocessor 8086 instructions
Microprocessor 8086 instructionsMicroprocessor 8086 instructions
Microprocessor 8086 instructions
 
1344 Alp Of 8086
1344 Alp Of 80861344 Alp Of 8086
1344 Alp Of 8086
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 
Lecture6
Lecture6Lecture6
Lecture6
 
Wk1to4
Wk1to4Wk1to4
Wk1to4
 
Chap03[1]
Chap03[1]Chap03[1]
Chap03[1]
 
Home works summary.pptx
Home works summary.pptxHome works summary.pptx
Home works summary.pptx
 
Chapter1c
Chapter1cChapter1c
Chapter1c
 
lec15_x86procedure_4up.pdf
lec15_x86procedure_4up.pdflec15_x86procedure_4up.pdf
lec15_x86procedure_4up.pdf
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
other-architectures.ppt
other-architectures.pptother-architectures.ppt
other-architectures.ppt
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter ppt
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4
 
Programming basic computer
Programming basic computerProgramming basic computer
Programming basic computer
 
Microprocessor system - summarize
Microprocessor system - summarizeMicroprocessor system - summarize
Microprocessor system - summarize
 

More from Jonah Marrs (9)

Sensors class
Sensors classSensors class
Sensors class
 
Etapes fab-venti-v2
Etapes fab-venti-v2Etapes fab-venti-v2
Etapes fab-venti-v2
 
Arduino coding class part ii
Arduino coding class part iiArduino coding class part ii
Arduino coding class part ii
 
Arduino coding class
Arduino coding classArduino coding class
Arduino coding class
 
Arduino creative coding class part iii
Arduino creative coding class part iiiArduino creative coding class part iii
Arduino creative coding class part iii
 
Arduino workshop
Arduino workshopArduino workshop
Arduino workshop
 
Shop bot training
Shop bot trainingShop bot training
Shop bot training
 
Microcontroller primer
Microcontroller primerMicrocontroller primer
Microcontroller primer
 
Eagle pcb tutorial
Eagle pcb tutorialEagle pcb tutorial
Eagle pcb tutorial
 

Recently uploaded

CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
AbrahamGadissa
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
Kamal Acharya
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 

Recently uploaded (20)

ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Introduction to Casting Processes in Manufacturing
Introduction to Casting Processes in ManufacturingIntroduction to Casting Processes in Manufacturing
Introduction to Casting Processes in Manufacturing
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
 
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfA CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
shape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxshape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptx
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Toll tax management system project report..pdf
Toll tax management system project report..pdfToll tax management system project report..pdf
Toll tax management system project report..pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 

Assembly class