Assembly Programming Sir Joseph Lindo University of the Cordilleras
description
Transcript of Assembly Programming Sir Joseph Lindo University of the Cordilleras
![Page 1: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/1.jpg)
Joseph L. Lindo
Assembly Programming
Sir Joseph LindoUniversity of the Cordilleras
![Page 2: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/2.jpg)
Joseph L. Lindo
Data
+ and -
Section 1
Assembly Programming
Registers• Named storage locations inside the CPU, optimized for speed.
• High speed storage locations directly inside the MPU
Registers
![Page 3: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/3.jpg)
Joseph L. Lindo
Data
+ and -
Section 1
Assembly Programming
Registers• There are 8 general purpose registers, 6 segment registers, Eflags registers and instruction pointers.
Registers
![Page 4: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/4.jpg)
Joseph L. Lindo
Data
+ and -
Registers
Assembly ProgrammingInstruction
Operand Types:Immediate – a constant integer (8,
16, or 32 bits)Register – the name of a register is
converted to a number and encoded within the instruction
Memory – reference to a location in memory
Data
![Page 5: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/5.jpg)
Joseph L. Lindo
Data
+ and -
Registers
Assembly Programming
Data Transfer Mnemonics
Data
![Page 6: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/6.jpg)
Joseph L. Lindo
Data
+ and -
Registers
Assembly Programming
Addition andSubtraction
+ and -
![Page 7: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/7.jpg)
Joseph L. Lindo
Assembly Programming
--end--
Sir Joseph LindoUniversity of the Cordilleras
![Page 8: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/8.jpg)
Joseph L. Lindo
Assembly Programming
--end na to--
Sir Joseph LindoUniversity of the Cordilleras
![Page 9: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/9.jpg)
Joseph L. Lindo
CPU vs MPU
Online Task
Provide the differences between CPU and MPU. Post it as comment on our FB Group. (COAL)
Due on February 21, 2012
![Page 10: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/10.jpg)
Joseph L. Lindo
General Purpose Registers
Registers
Primarily used for arithmetic and data movement.
Each register could be addressed as either 8, 16 or 32 bit value.
![Page 11: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/11.jpg)
Joseph L. Lindo
General Purpose Registers
Registers
![Page 12: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/12.jpg)
Joseph L. Lindo
MOV
Data Transfer
Moves data fro source to destinationSyntax:
MOV destination,source
Rules: Destination should not be an immediate
operand
![Page 13: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/13.jpg)
Joseph L. Lindo
MOV
Data Transfer
.datacount BYTE 100wVal WORD 2
.codemov bl,countmov al,wValmov ax,wValmov count,almov ax,countmov eax,count
![Page 14: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/14.jpg)
Joseph L. Lindo
MOV
Data Transfer
Code AX BX
MOV ah,10
MOV ax,35
MOV bh,al
MOV bx,1234
MOV bl,04
MOV bh,55
![Page 15: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/15.jpg)
Joseph L. Lindo
XCHG
Data Transfer
XCHG exchanges the values of two operands. Syntax:
XCHG operand1,operand2
Rules:
At least one operand must be a register.
No immediate operands are permitted.
![Page 16: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/16.jpg)
Joseph L. Lindo
XCHG
Data Transfer
.datavar1 WORD 1000hvar2 WORD 2000h
.codexchg ax,bxxchg ah,alxchg var1,bxxchg 3,100xchg eax,ebxxchg var1,var2
![Page 17: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/17.jpg)
Joseph L. Lindo
XCHG
Data Transfer
Code AX BX
MOV bx,4810
MOV ax,35
XCHG bh,bl
XCHG bh,ah
MOV bl,04
XCHG bl,al
![Page 18: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/18.jpg)
Joseph L. Lindo
INC and DEC
Add and Sub
Add 1, subtract 1 from destination operandoperand may be register or memory
INC destinationLogic: destination destination + 1
DEC destination Logic: destination destination – 1
![Page 19: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/19.jpg)
Joseph L. Lindo
INC and DEC
Add and Sub
.datamyWord WORD 1000hmyDword DWORD 10000000h
.codeinc myWord dec myWordinc myDwordmov ax,00FFhinc axmov ax,00FFhinc al
![Page 20: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/20.jpg)
Joseph L. Lindo
INC and DEC
Add and Sub
Code AX BX
MOV ah,10
MOV al,35
INC al
MOV bx,1234
DEC bl
INC bh
![Page 21: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/21.jpg)
Joseph L. Lindo
ADD and SUB
Add and Sub
ADD destination, sourceLogic: destination destination + source
SUB destination, sourceLogic: destination destination – source
Same operand rules as for the MOV instruction
![Page 22: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/22.jpg)
Joseph L. Lindo
ADD and SUB
Add and Sub
.datavar1 DWORD 10000hvar2 DWORD 20000h
.codemov eax,var1add eax,var2add var2,var1 add ax,0FFFFhsub 1,2sub var1,var2add eax,1sub ax,1
![Page 23: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/23.jpg)
Joseph L. Lindo
ADD and SUB
Add and Sub
Code AX BX
MOV ah,10
MOV al,35
ADD ah,al
MOV bx,1294
SUB bl,ah
ADD ax,bh
![Page 24: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/24.jpg)
Joseph L. Lindo
MOV and XCHG
Comprehension Check
![Page 25: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/25.jpg)
Joseph L. Lindo
INC, DEC ADD and SUB
Comprehension Check
![Page 26: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/26.jpg)
Joseph L. Lindo
Assembly Programming
--end--
Sir Joseph LindoUniversity of the Cordilleras
![Page 27: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/27.jpg)
Joseph L. Lindo
Back
Integer Expressions
![Page 28: Assembly Programming Sir Joseph Lindo University of the Cordilleras](https://reader036.fdocuments.net/reader036/viewer/2022062518/56814369550346895dafe72e/html5/thumbnails/28.jpg)
Joseph L. Lindo
INC and DEC
MOV
Reserved Word and Identifiers
Directives
Character and String Constants
ADD and SUB
More
XCHG