Presentation is loading. Please wait.

Presentation is loading. Please wait.

Joseph L. Lindo Assembly Programming Sir Joseph Lindo University of the Cordilleras.

Similar presentations


Presentation on theme: "Joseph L. Lindo Assembly Programming Sir Joseph Lindo University of the Cordilleras."— Presentation transcript:

1 Joseph L. Lindo Assembly Programming Sir Joseph Lindo University of the Cordilleras

2 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

3 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

4 Joseph L. Lindo Set-up Basics Define Assembly Programming Programming Environment Softwares Needed: Text Editor Assembler Emulator Set-up

5 Joseph L. Lindo Set-up Basics Define Assembly Programming Running Programs Set-up Save the TEXT file with extension name.ASM Ex. Sample.asm Using the CMD Compile: - ….\TASM> tasm Sample.asm

6 Joseph L. Lindo Set-up Basics Define Assembly Programming Running Programs Set-up Create the executable file - ….\TASM> tlink Sample Execute -….\TASM> tlink Sample

7 Joseph L. Lindo Set-up Basics Define Assembly Programming Basic Elements Basics

8 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.

9 Joseph L. Lindo Assembly Programming --end-- Sir Joseph Lindo University of the Cordilleras

10 Joseph L. Lindo Assembly Programming --end na to-- Sir Joseph Lindo University of the Cordilleras

11 Joseph L. Lindo Comparison of Assembly to HL Assembly Language

12 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. TASM MASM FASM NASM WASM Due on February 21, 2012

13 Joseph L. Lindo Assembly Link Execute Cycle Assembly Language

14 Joseph L. Lindo Integer Constants Basic Elements Optional leading + or – sign Binary, Decimal, Hexadecimal digits Common radix characters: h – hexadecimal d – decimal b – binary Examples: 30d, 6Ah, 42, 1101b

15 Joseph L. Lindo Integer Expressions Basic Elements Precedence Rule Examples

16 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'

17 Joseph L. Lindo Reserved Words and Identifiers Basic Elements Reserved words cannot be used as identifiers Instruction mnemonics, directives, type attributes, operators, predefined symbols Identifiers 1-247 characters, including digits case insensitive (by default) first character must be a letter, _, @, or $

18 Joseph L. Lindo Directives Basic Elements Commands that are recognized and acted upon by the assembler Not part of the Intel instruction set Used to declare code, data areas, select memory model, declare procedures, etc. Different assemblers have different directives TASM != MASM, for example

19 Joseph L. Lindo Directives Basic Elements.MODEL It identifies the size of code and data a program could have Syntax:

20 Joseph L. Lindo Directives Basic Elements.STACK It sets aside a block of memory to store the stack Syntax: [size]

21 Joseph L. Lindo Directives Basic Elements.DATA It contains variables and constants definition Syntax:

22 Joseph L. Lindo Directives Basic Elements.CODE It contains program’s instructions Syntax:

23 Joseph L. Lindo Memory Models Directives

24 Joseph L. Lindo Instructions Basic Elements Assembled into machine code by assembler Executed at runtime by the CPU Member of the Intel IA-32 instruction set Parts: Label Mnemonic Operand Comment

25 Joseph L. Lindo Labels Instructions Act as place markers marks the address (offset) of code and data Data label must be unique Code label target of jump and loop instructions Follow identifier rules

26 Joseph L. Lindo Mnemonics and Operands Instructions Instruction Mnemonics "reminder" examples: MOV, ADD, SUB, MUL, INC, DEC Operands constant (immediate value) constant expression register memory (data label)

27 Joseph L. Lindo Comments Instructions Comments are good! explain the program's purpose tricky coding techniques application-specific explanations Single-line comments begin with semicolon (;) Multi-line comments begin with COMMENT directive and a character end with the same character

28 Joseph L. Lindo Examples Instructions No operands stc ; set Carry flag One operand inc ax ; register inc myByte ; memory Two operands add bx,cx ; register, register sub myByte,25 ; memory, constant add ax,36 * 25 ; register, expression

29 Joseph L. Lindo Defining Variables Data Definition Intrinsic Data Type

30 Joseph L. Lindo Defining Variables Data Definition Syntax [name] Data Type value [,value] … Using DUP name Data Type size DUP (value)

31 Joseph L. Lindo Assembly Programming --end-- Sir Joseph Lindo University of the Cordilleras


Download ppt "Joseph L. Lindo Assembly Programming Sir Joseph Lindo University of the Cordilleras."

Similar presentations


Ads by Google