assembly programming sir joseph lindo university of the cordilleras
DESCRIPTION
Assembly Programming Sir Joseph Lindo University of the Cordilleras. Assembly Programming. Definition. Section 1. Assembly Language. Low level language Instruction mnemonics (Instruction Set) that have a one-to-one correspondence to machine language - PowerPoint PPT PresentationTRANSCRIPT
Joseph L. Lindo
Assembly Programming
Sir Joseph LindoUniversity of the Cordilleras
Joseph L. Lindo
Set-up
Basics
Section 1
Assembly Programming
Assembly Language• Low level language
• Instruction mnemonics (Instruction Set) that have a one-to-one correspondence to machine language
•Calls functions written at the operating system level
Definition
Joseph L. Lindo
Set-up
Basics
Section 1
Assembly Programming
Assembly Applications• Business application for single platform
•Hardware device driver
•Business application for multiple platforms
•Embedded systems & computer games
Definition
Joseph L. Lindo
Set-up
Basics
Define
Assembly ProgrammingProgrammingEnvironment
Softwares Needed:
• Text Editor• Assembler• Emulator
Set-up
Joseph L. Lindo
Set-up
Basics
Define
Assembly Programming
Running Programs
Set-upSave the TEXT file with extension name .ASM
Ex. Sample.asm
Using the CMD
Compile: - ….\TASM> tasm Sample.asm
Joseph L. Lindo
Set-up
Basics
Define
Assembly Programming
Running Programs
Set-upCreate the executable file - ….\TASM> tlink Sample
Execute -….\TASM> tlink Sample
Joseph L. Lindo
Set-up
Basics
Define
Assembly Programming
Basic Elements
Basics
Joseph L. Lindo
Set-up
Basics
Define
Assembly Programming
Data Definition
Basics
A data definition statements sets aside storage in memory for variable and assign a name to the variable.
Joseph L. Lindo
Assembly Programming
--end--
Sir Joseph LindoUniversity of the Cordilleras
Joseph L. Lindo
Assembly Programming
--end na to--
Sir Joseph LindoUniversity of the Cordilleras
Joseph L. Lindo
Comparison of Assembly to HL
Assembly Language
Joseph L. Lindo
Assemblers
Online Task
Divide the class according to the assemblers below. Members are required to post possible knowledge about the assigned assembler.TASMMASMFASMNASMWASM
Due on February 21, 2012
Joseph L. Lindo
Assembly Link Execute Cycle
Assembly Language
SourceFile
ObjectFile
ListingFile
LinkLibrary
ExecutableFile
MapFile
Output
Step 1: text editor
Step 2:assembler
Step 3:linker
Step 4:OS loader
Joseph L. Lindo
Integer Constants
Basic Elements
Optional leading + or – signBinary, Decimal, Hexadecimal digitsCommon radix characters:
h – hexadecimald – decimalb – binary
Examples: 30d, 6Ah, 42, 1101b
Joseph L. Lindo
Integer Expressions
Basic Elements
Precedence Rule
Examples
Joseph L. Lindo
Character and String Constants
Basic Elements
Enclose character in single or double quotes'A', "x"ASCII character = 1 byte
Enclose strings in single or double quotes"ABC"'xyz'Each character occupies a single byte
Embedded quotes:'Say "Goodnight," Gracie'
Joseph L. Lindo
Reserved Words and Identifiers
Basic Elements
Reserved words cannot be used as identifiersInstruction mnemonics, directives, type attributes, operators, predefined symbols
Identifiers1-247 characters, including digitscase insensitive (by default)first character must be a letter, _, @, or $
Joseph L. Lindo
Directives
Basic Elements
Commands that are recognized and acted upon by the assembler
Not part of the Intel instruction setUsed to declare code, data areas, select memory model, declare procedures, etc.
Different assemblers have different directivesTASM != MASM, for example
Joseph L. Lindo
Directives
Basic Elements
.MODEL
It identifies the size of code and data a program could have
Syntax: <.MODEL> <memory model>
Joseph L. Lindo
Directives
Basic Elements
.STACK
It sets aside a block of memory to store the stack
Syntax: <.STACK> [size]
Joseph L. Lindo
Directives
Basic Elements
.DATA
It contains variables and constants definition
Syntax: <.DATA>
Joseph L. Lindo
Directives
Basic Elements
.CODE
It contains program’s instructions
Syntax: <.CODE>
Joseph L. Lindo
Memory Models
Directives
Joseph L. Lindo
Instructions
Basic Elements
Assembled into machine code by assemblerExecuted at runtime by the CPUMember of the Intel IA-32 instruction setParts:
LabelMnemonicOperandComment
Joseph L. Lindo
Labels
Instructions
Act as place markersmarks the address (offset) of code and data
Data labelmust be unique
Code labeltarget of jump and loop instructions
Follow identifier rules
Joseph L. Lindo
Mnemonics and Operands
Instructions
Instruction Mnemonics"reminder"examples: MOV, ADD, SUB, MUL, INC, DEC
Operandsconstant (immediate value)constant expressionregistermemory (data label)
Joseph L. Lindo
Comments
Instructions
Comments are good!explain the program's purposetricky coding techniquesapplication-specific explanations
Single-line commentsbegin with semicolon (;)
Multi-line commentsbegin with COMMENT directive and a character end with the same character
Joseph L. Lindo
Examples
Instructions
No operandsstc ; set Carry flag
One operandinc ax ; registerinc myByte ; memory
Two operandsadd bx,cx ; register, registersub myByte,25 ; memory, constantadd ax,36 * 25 ; register, expression
Joseph L. Lindo
Defining Variables
Data Definition
Intrinsic Data Type
Joseph L. Lindo
Defining Variables
Data Definition
Syntax
[name] Data Type value [,value] …
Using DUP
name Data Type size DUP (value)
Joseph L. Lindo
Assembly Programming
--end--
Sir Joseph LindoUniversity of the Cordilleras