280 likes | 403 Vues
Assembly Programming Sir Joseph Lindo University of the Cordilleras. Assembly Programming. Registers. Section 1. Registers. Named storage locations inside the CPU, optimized for speed. High speed storage locations directly inside the MPU. Data. + and -. Assembly Programming.
E N D
Assembly Programming Sir Joseph Lindo University of the Cordilleras
Assembly Programming Registers Section 1 Registers • Named storage locations inside the CPU, optimized for speed. • High speed storage locations directly inside the MPU Data + and -
Assembly Programming Registers Section 1 Registers • There are 8 general purpose registers, 6 segment registers, Eflags registers and instruction pointers. Data + and -
Assembly Programming Instruction Registers Data Data • 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 + and -
Assembly Programming Data Transfer Mnemonics Registers Data Data + and -
Assembly Programming Addition and Subtraction Registers Data + and - + and -
Assembly Programming --end-- Sir Joseph Lindo University of the Cordilleras
Assembly Programming --end na to-- Sir Joseph Lindo University of the Cordilleras
Online Task CPU vs MPU Provide the differences between CPU and MPU. Post it as comment on our FB Group. (COAL) Due on February 21, 2012
Registers General Purpose Registers Primarily used for arithmetic and data movement. Each register could be addressed as either 8, 16 or 32 bit value.
Registers General Purpose Registers
Data Transfer MOV Moves data fro source to destination Syntax: MOV destination,source Rules: Destination should not be an immediate operand
Data Transfer MOV .data count BYTE 100 wVal WORD 2 .code movbl,count moval,wVal movax,wVal movcount,al movax,count moveax,count
Data Transfer MOV
Data Transfer XCHG 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.
Data Transfer XCHG .data var1 WORD 1000h var2 WORD 2000h .code xchgax,bx xchgah,al xchg var1,bx xchg 3,100 xchgeax,ebx xchg var1,var2
Data Transfer XCHG
Add and Sub INC and DEC • Add 1, subtract 1 from destination operand • operand may be register or memory • INC destination • Logic: destination destination + 1 • DEC destination • Logic: destination destination – 1
Add and Sub INC and DEC .data myWord WORD 1000h myDword DWORD 10000000h .code inc myWord decmyWord inc myDword mov ax,00FFh inc ax mov ax,00FFh inc al
Add and Sub INC and DEC
Add and Sub ADD and SUB • ADD destination, source • Logic: destination destination + source • SUB destination, source • Logic: destination destination – source • Same operand rules as for the MOV instruction
Add and Sub ADD and SUB .data var1 DWORD 10000h var2 DWORD 20000h .code mov eax,var1 add eax,var2 add var2,var1 add ax,0FFFFh sub 1,2 sub var1,var2 add eax,1 sub ax,1
Add and Sub ADD and SUB
Comprehension Check MOV and XCHG
Comprehension Check INC, DEC ADD and SUB
Assembly Programming --end-- Sir Joseph Lindo University of the Cordilleras
Back Integer Expressions
INC and DEC MOV XCHG Directives Character and String Constants Reserved Word and Identifiers ADD and SUB More