1 / 31

Assembly Programming Sir Joseph Lindo University of the Cordilleras

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

anahid
Download Presentation

Assembly Programming Sir Joseph Lindo University of the Cordilleras

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Assembly Programming Sir Joseph Lindo University of the Cordilleras

  2. Assembly Programming Definition Section 1 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 Set-up Basics

  3. Assembly Programming Definition Section 1 Assembly Applications • Business application for single platform • Hardware device driver • Business application for multiple platforms • Embedded systems & computer games Set-up Basics

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

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

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

  7. Assembly Programming Basic Elements Define Set-up Basics Basics

  8. Assembly Programming Data Definition Define • A data definition statements sets aside storage in memory for variable and assign a name to the variable. Set-up Basics Basics

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

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

  11. Assembly Language Comparison of Assembly to HL

  12. Online Task Assemblers 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. Assembly Language Assembly Link Execute Cycle

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

  15. Basic Elements Integer Expressions • Precedence Rule Examples

  16. Basic Elements Character and String Constants • 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. Basic Elements Reserved Words and Identifiers • 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. Basic Elements Directives • 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. Basic Elements Directives .MODEL It identifies the size of code and data a program could have Syntax: <.MODEL> <memory model>

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

  21. Basic Elements Directives .DATA It contains variables and constants definition Syntax: <.DATA>

  22. Basic Elements Directives .CODE It contains program’s instructions Syntax: <.CODE>

  23. Directives Memory Models

  24. Basic Elements Instructions • 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. Instructions Labels • 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. Instructions Mnemonics and Operands • Instruction Mnemonics • "reminder" • examples: MOV, ADD, SUB, MUL, INC, DEC • Operands • constant (immediate value) • constant expression • register • memory (data label)

  27. Instructions Comments • 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. Instructions Examples • 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. Data Definition Defining Variables • Intrinsic Data Type

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

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

More Related