von Neumann <ul><li>Stored Program concept </li></ul><ul><li>Main memory storing programs and data </li></ul><ul><li>ALU c...
von Neumann
von Neumann <ul><li>1000 x 40 bit words </li></ul><ul><ul><li>Binary number </li></ul></ul><ul><ul><li>2 x 20 bit instruct...
Moore’s Law <ul><li>Increased density of components on chip </li></ul><ul><li>Gordon Moore - cofounder of Intel </li></ul>...
Speeding it up  <ul><li>Pipelining </li></ul><ul><li>On board cache </li></ul><ul><li>On board L1 & L2 cache </li></ul><ul...
Intel 8086 & 8088 <ul><li>The 8086 is a 16-bit microprocessor chip designed by Intel and introduced on the market in 1978,...
Segmentation <ul><li>Compilers for the 8086 commonly supported two types of pointer, &quot;near&quot; and &quot;far&quot;....
Segmentation <ul><li>To avoid the need to specify &quot;near&quot; and &quot;far&quot; on every pointer and every function...
 
 
 
x86 Registers Category  Category Bit  Register Name General Purpose Register 32/16 E/AX,E/BX,E/CX,E/DX General Purpose Reg...
General Purpose Registers <ul><li>This register is used for general data manipulation </li></ul><ul><li>Even CPU able to o...
8-bit Data Division from 16-bit <ul><li>16-bit register can be divided into two 8-bit register (i.e AX=AH&AL, BX=BH&BL, CX...
16-bit Data form into 32-bit <ul><li>Similarly, 32-bit register can be made from 16-bit register i.e  </li></ul><ul><li>EA...
 
Segment Register <ul><li>Main memory management in 8086 use segment concept </li></ul><ul><li>The following show the usage...
 
Instruction Pointer Register (IP) <ul><li>Register which stores instruction address to be executed </li></ul><ul><li>Each ...
Index Register and Pointer <ul><li>This registers is used for storing relative shifting value for memory address location ...
 
 
Assembler  <ul><li>An  assembler  translates assembly language programs into machine codes </li></ul><ul><li>It resolves s...
Assembler  <ul><li>There are two types of assemblers based on how many passes through the source are needed to produce the...
Assembler  <ul><li>As a result, the program can be defined in a more logical and meaningful way.  </li></ul><ul><li>This m...
Variable Declarations  <ul><li>Our compiler supports two types of variables:  BYTE  and  WORD .   </li></ul><ul><li>Syntax...
<ul><li>Syntax for a variable declaration: name   DB   value name   DW   value DB  - stays for  D efine  B yte. DW  - stay...
Declare Variables <ul><li>use DB to declare variables with small values 0 to 255. </li></ul><ul><li>use DW  to declare var...
comments / remarks <ul><li>C++: comments denoted by // </li></ul><ul><li>anything after // will be ignored </li></ul><ul><...
Simple Assignments <ul><li>The easiest expressions to convert to assembly language are the simple assignments. </li></ul><...
Small Sample Program <ul><ul><li>ORG 100h  </li></ul></ul><ul><ul><li>MOV AL, var1  </li></ul></ul><ul><ul><li>MOV BX, var...
ORG <ul><li>Program start address </li></ul><ul><li>ORG 100H </li></ul><ul><li>normally start at address 100H (hexadecimal...
RET <ul><li>similar to C++ return statement. </li></ul>
Simple Assignments(MOV) <ul><li>The easiest expressions to convert to assembly language are the simple assignments. </li><...
<ul><li>It is possible to enter numbers in any system, hexadecimal numbers should have &quot; h &quot; suffix, binary &quo...
Assembler Directive/Pseudo-Ops <ul><li>2 types of ASM statements </li></ul><ul><li>program instruction  </li></ul><ul><ul>...
<ul><li>This example assignment copies a variable into a variable </li></ul><ul><li>P := Q </li></ul><ul><li>The assignmen...
Addition (ADD)  <ul><li>Examples of common simple expressions: </li></ul><ul><li>X := Y + Z </li></ul><ul><li>ASM: </li></...
Arithmetic Expressions <ul><li>Arithmetic expressions, in most high level languages, look similar to their algebraic equiv...
Arithmatic Expressions <ul><li>A math expression takes the form: </li></ul><ul><li>var := term1 op term2 </li></ul><ul><li...
SUBTRACT (SUB) <ul><li>X := Y - Z; </li></ul><ul><li>ASM: </li></ul><ul><li>mov ax, y ;ax=y </li></ul><ul><li>sub ax, z ;a...
INCREMENT (INC) <ul><li>X := X + 1; </li></ul><ul><li>ASM: </li></ul><ul><li>inc x </li></ul>
DECREMENT (DEC) <ul><li>X := X - 1; </li></ul><ul><li>ASM: </li></ul><ul><li>dec x </li></ul>
Instruction Format <ul><li>instruction has  opcode  +  operand (s) </li></ul><ul><ul><ul><ul><li>ADD AX, 2 </li></ul></ul>...
Arithmetic Expressions <ul><li>Arithmetic expressions, in most high level languages, look similar to their algebraic equiv...
Complex Expressions <ul><li>A complex function that is easy to convert to assembly language is one that involves </li></ul...
Complex Expressions <ul><li>Clearly the straight-forward assembly language conversion of this statement will require two s...
Debuggers and Debugging  <ul><li>The final, and almost certainly the most painful, part of the assembly language developme...
Debuggers and Debugging  <ul><li>One of the problems with debugging computer programs is that they operate so quickly.  </...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Opcode mnemonics  <ul><li>Instructions (statements) in assembly language are generally very simple, unlike those in high-l...
Assembly directives / pseudo-ops  <ul><li>Assembly Directives are instructions that are executed by the Assembler at assem...
Assembling the Source Code File  <ul><li>The text editor first creates a new text file, and later changes that same text f...
Assembling the Source Code File <ul><li>Each type of file will have its own standard file extension. </li></ul><ul><li>Any...
Assembling the Source Code File <ul><li>The assembler will open the source code file you named after the name of the assem...
Linking  <ul><li>In traditional assembly language work, what actually happens is that the assembler writes an intermediate...
Debuggers and Debugging  <ul><li>The final, and almost certainly the most painful, part of the assembly language developme...
Debuggers and Debugging  <ul><li>One of the problems with debugging computer programs is that they operate so quickly.  </...
Upcoming SlideShare
Loading in...5
×

Wk1to4

205

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
205
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Wk1to4"

  1. 1. von Neumann <ul><li>Stored Program concept </li></ul><ul><li>Main memory storing programs and data </li></ul><ul><li>ALU calculating data </li></ul><ul><li>Control unit interpreting instructions from memory and executing </li></ul><ul><li>Input and output equipment operated by control unit </li></ul>
  2. 2. von Neumann
  3. 3. von Neumann <ul><li>1000 x 40 bit words </li></ul><ul><ul><li>Binary number </li></ul></ul><ul><ul><li>2 x 20 bit instructions </li></ul></ul><ul><li>Set of registers (storage in CPU) </li></ul><ul><ul><li>Memory Buffer Register </li></ul></ul><ul><ul><li>Memory Address Register </li></ul></ul><ul><ul><li>Instruction Register </li></ul></ul><ul><ul><li>Instruction Buffer Register </li></ul></ul><ul><ul><li>Program Counter </li></ul></ul><ul><ul><li>Accumulator </li></ul></ul><ul><ul><li>Multiplier Quotient </li></ul></ul>
  4. 4. Moore’s Law <ul><li>Increased density of components on chip </li></ul><ul><li>Gordon Moore - cofounder of Intel </li></ul><ul><li>Number of transistors on a chip will double every year </li></ul><ul><li>Since 1970’s development has slowed a little </li></ul><ul><ul><li>Number of transistors doubles every 18 months </li></ul></ul><ul><li>Cost of a chip has remained almost unchanged </li></ul><ul><li>Higher packing density means shorter electrical paths, giving higher performance </li></ul><ul><li>Smaller size gives increased flexibility </li></ul><ul><li>Reduced power and cooling requirements </li></ul><ul><li>Fewer interconnections increases reliability </li></ul>
  5. 5. Speeding it up <ul><li>Pipelining </li></ul><ul><li>On board cache </li></ul><ul><li>On board L1 & L2 cache </li></ul><ul><li>Branch prediction </li></ul><ul><li>Data flow analysis </li></ul><ul><li>Speculative execution </li></ul>
  6. 6. Intel 8086 & 8088 <ul><li>The 8086 is a 16-bit microprocessor chip designed by Intel and introduced on the market in 1978, which gave rise to the x86 architecture. </li></ul><ul><li>Intel 8088, released in 1979, was essentially the same chip, but with an external 8-bit data bus (allowing the use of cheaper and fewer supporting logic chips), and is notable as the processor used in the original IBM PC. </li></ul>
  7. 7. Segmentation <ul><li>Compilers for the 8086 commonly supported two types of pointer, &quot;near&quot; and &quot;far&quot;. </li></ul><ul><li>Near pointers were 16-bit addresses implicitly associated with the program's code or data segment (and so made sense only in programs small enough to fit in one segment). </li></ul><ul><li>Far pointers were 32-bit segment:offset pairs. </li></ul>
  8. 8. Segmentation <ul><li>To avoid the need to specify &quot;near&quot; and &quot;far&quot; on every pointer and every function which took or returned a pointer, compilers also supported &quot;memory models&quot; which specified default pointer sizes. </li></ul><ul><li>The &quot;small&quot;, &quot;compact&quot;, &quot;medium&quot;, and &quot;large&quot; models covered every combination of near and far pointers for code and data. </li></ul><ul><li>The &quot;tiny&quot; model was like &quot;small&quot; except that code and data shared one segment. </li></ul><ul><li>The &quot;huge&quot; model was like &quot;large&quot; except that all pointers were huge instead of far by default. Precompiled libraries often came in several versions compiled for different memory models. </li></ul>
  9. 12. x86 Registers Category Category Bit Register Name General Purpose Register 32/16 E/AX,E/BX,E/CX,E/DX General Purpose Register 8 AH,AL,BH,BL,CH,CL,DH,DL Pointer Register 32/16 E/SP (Stack Pointer) E/BP (Base Pointer) Index Register 32/16 E/SI (Source Index) E/DI (Destination Index) Segment Register 32/16 CS (Code Segment) DS (Data Segment) SS (Stack Segment) ES (Extra Segment) Instruction Pointer Register 32/16 E/IP (Instruction Pointer) Status Register (Flag) 32/16 E/FLAGS (Flag Register)
  10. 13. General Purpose Registers <ul><li>This register is used for general data manipulation </li></ul><ul><li>Even CPU able to operate on the data stored in memory, the same data can be process much faster if it is in register </li></ul>Register Function E/AX Accumulator Register For arithmetic, logic and data transfer operation E/BX Base Register Also as address register E/CX Count Register Used for loop counter, shift and rotate bits E/DX Data Register Used in division and multiplication also I/O operation
  11. 14. 8-bit Data Division from 16-bit <ul><li>16-bit register can be divided into two 8-bit register (i.e AX=AH&AL, BX=BH&BL, CX=CH&CL, DX=DH&DL) </li></ul>Figure 1: 8-bit Data Division from 16-bit
  12. 15. 16-bit Data form into 32-bit <ul><li>Similarly, 32-bit register can be made from 16-bit register i.e </li></ul><ul><li>EAX=undefined 16 bits +AX </li></ul><ul><li>EBX=undefined 16 bits +BX ECX=undefined 16 bits +CX EDX=undefined 16 bits +DX </li></ul>
  13. 17. Segment Register <ul><li>Main memory management in 8086 use segment concept </li></ul><ul><li>The following show the usage of segment in memory </li></ul>Segment Usage Code (CS) Space to store program that will be executed Data (DS) Space to store data that will be processed Stack (SS) Special space to store information needed by microprocessor to execute subroutine or interrupt service Extra (ES) Function is the same as DS
  14. 19. Instruction Pointer Register (IP) <ul><li>Register which stores instruction address to be executed </li></ul><ul><li>Each time instruction is fetch from memory to be executed in processor, IP content will be added so that it always show to the next instruction </li></ul><ul><li>If branch instruction, the IP content will be loaded with new value which is the branch address </li></ul>
  15. 20. Index Register and Pointer <ul><li>This registers is used for storing relative shifting value for memory address location </li></ul><ul><li>There are 2 pointer register: </li></ul><ul><ul><li>Stack Pointer (SP) – point to the top stack </li></ul></ul><ul><ul><li>Base Pointer (BP) – used for fetch data in data segment </li></ul></ul><ul><li>There are 2 index register: </li></ul><ul><ul><li>Source Index (SI) – contains offset address for source operand in data segment </li></ul></ul><ul><ul><li>Destination Index (DI) - contains offset value for destination operand in DS </li></ul></ul>
  16. 23. Assembler <ul><li>An assembler translates assembly language programs into machine codes </li></ul><ul><li>It resolves symbolic names for memory locations and other entities. </li></ul>
  17. 24. Assembler <ul><li>There are two types of assemblers based on how many passes through the source are needed to produce the executable program. </li></ul><ul><li>One-pass assemblers go through the source code once and assumes that all symbols will be defined before any instruction that references them. </li></ul><ul><li>Two-pass assemblers (and multi-pass assemblers) create a table with all unresolved symbols in the first pass, then use the 2nd pass to resolve these addresses. </li></ul><ul><li>The advantage of the two-pass assembler is that symbols can be defined anywhere in the program source. </li></ul>
  18. 25. Assembler <ul><li>As a result, the program can be defined in a more logical and meaningful way. </li></ul><ul><li>This makes two-pass assembler programs easier to read and maintain. </li></ul>
  19. 26. Variable Declarations <ul><li>Our compiler supports two types of variables: BYTE and WORD . </li></ul><ul><li>Syntax for a variable declaration: name DB value name DW value </li></ul><ul><li>DB - stays for D efine B yte. DW - stays for D efine W ord. </li></ul>
  20. 27. <ul><li>Syntax for a variable declaration: name DB value name DW value DB - stays for D efine B yte. DW - stays for D efine W ord. name - can be any letter or digit combination </li></ul><ul><li>value - can be any numeric value in any supported numbering system (hexadecimal, binary, or decimal), or &quot; ? &quot; symbol for variables that are not initialized. </li></ul>Variable Declarations
  21. 28. Declare Variables <ul><li>use DB to declare variables with small values 0 to 255. </li></ul><ul><li>use DW to declare variables with larger values 0 to 65000. </li></ul><ul><li>C++: int HT=47, WD=2415, SZ; </li></ul><ul><li>ASM: HT DB 47 </li></ul><ul><li>WD DW 2415 </li></ul><ul><li>SZ DW ? </li></ul><ul><li>unitialised value in ASM is denoted by ? </li></ul>
  22. 29. comments / remarks <ul><li>C++: comments denoted by // </li></ul><ul><li>anything after // will be ignored </li></ul><ul><li>in ASM: comments denoted by ; </li></ul><ul><li>anything after ; will be ignored </li></ul><ul><li>C++ has multi-line comments enclosed by /* and */. In ASM, each comment line must be individually preceded by ; </li></ul>
  23. 30. Simple Assignments <ul><li>The easiest expressions to convert to assembly language are the simple assignments. </li></ul><ul><li>MOV instruction </li></ul><ul><li>Simple assignments copy a single value into a variable </li></ul><ul><li>variable := value </li></ul><ul><li>Eg: C++: P = 5; </li></ul><ul><ul><ul><ul><li>ASM: MOV P, 5 </li></ul></ul></ul></ul><ul><li>This move immediate instruction copies the constant into the variable. </li></ul>
  24. 31. Small Sample Program <ul><ul><li>ORG 100h </li></ul></ul><ul><ul><li>MOV AL, var1 </li></ul></ul><ul><ul><li>MOV BX, var2 </li></ul></ul><ul><ul><li>RET ; stops the program. </li></ul></ul><ul><ul><li>VAR1 DB 7 </li></ul></ul><ul><ul><li>var2 DW 1234h </li></ul></ul>
  25. 32. ORG <ul><li>Program start address </li></ul><ul><li>ORG 100H </li></ul><ul><li>normally start at address 100H (hexadecimal) </li></ul>
  26. 33. RET <ul><li>similar to C++ return statement. </li></ul>
  27. 34. Simple Assignments(MOV) <ul><li>The easiest expressions to convert to assembly language are the simple assignments. </li></ul><ul><li>Simple assignments copy a single value into a variable </li></ul><ul><li>variable := constant </li></ul><ul><li>Eg: C++: P = 5; </li></ul><ul><ul><ul><ul><li>ASM: MOV P, 5 </li></ul></ul></ul></ul><ul><li>This move immediate instruction copies the constant into the variable. </li></ul>
  28. 35. <ul><li>It is possible to enter numbers in any system, hexadecimal numbers should have &quot; h &quot; suffix, binary &quot; b &quot; suffix, octal &quot; o &quot; suffix, decimal numbers require no suffix. </li></ul><ul><li>mov AX, 46 H ; hex </li></ul><ul><li>mov BX, 1011 B ; binary </li></ul><ul><li>mov AH, 251 o ; octal </li></ul><ul><li>mov CH, 36 ; decimal </li></ul>
  29. 36. Assembler Directive/Pseudo-Ops <ul><li>2 types of ASM statements </li></ul><ul><li>program instruction </li></ul><ul><ul><li>convert to machine code of the program, ADD, SUB, MUL, MOV, DIV, etc </li></ul></ul><ul><li>assembler directives (pseudo-ops ) </li></ul><ul><ul><li>does not convert to machine code of the program </li></ul></ul><ul><ul><li>info for the assembler eg: </li></ul></ul><ul><ul><ul><li>variable declaration DB, DW </li></ul></ul></ul><ul><ul><ul><li>program start address ORG </li></ul></ul></ul><ul><ul><ul><li>data, code, stack segment, .DATA, .CODE, .STACK </li></ul></ul></ul><ul><ul><ul><li>etc </li></ul></ul></ul>
  30. 37. <ul><li>This example assignment copies a variable into a variable </li></ul><ul><li>P := Q </li></ul><ul><li>The assignment above is somewhat complicated since the 80x86 doesn’t provide a memory–to-memory mov instruction. </li></ul><ul><li>Therefore, to copy one memory variable into another, you must move the data through a register. </li></ul><ul><li>Eg: C++: P = Q; </li></ul><ul><ul><ul><ul><li>ASM: MOV AX, Q ;AX = Q </li></ul></ul></ul></ul><ul><ul><li>MOV P, AX ;P=AX=Q </li></ul></ul>Assignments (MOV)
  31. 38. Addition (ADD) <ul><li>Examples of common simple expressions: </li></ul><ul><li>X := Y + Z </li></ul><ul><li>ASM: </li></ul><ul><li>mov ax, y ;ax=y </li></ul><ul><li>add ax, z ;ax=ax+z=y+z </li></ul><ul><li>mov x, ax ;x=ax=y+z </li></ul>
  32. 39. Arithmetic Expressions <ul><li>Arithmetic expressions, in most high level languages, look similar to their algebraic equivalents: </li></ul><ul><li>X:=Y+Z; </li></ul><ul><li>In assembly language, you’ll need several statements to accomplish this same task, e.g., </li></ul><ul><ul><ul><ul><ul><li>mov ax, y ;ax=y </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>add z ;ax=ax+y=z+y </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>mov x, ax ;x=ax=x+y </li></ul></ul></ul></ul></ul>
  33. 40. Arithmatic Expressions <ul><li>A math expression takes the form: </li></ul><ul><li>var := term1 op term2 </li></ul><ul><li>Var is a variable, term1 and term2 are variables or constants, and op is some arithmetic operator(+,-,*, /, etc) </li></ul><ul><li>ASM: op term1 term2 </li></ul><ul><li>where </li></ul><ul><li>op = ADD, SUB, MUL, IMUL, DIV, IDIV, etc </li></ul>
  34. 41. SUBTRACT (SUB) <ul><li>X := Y - Z; </li></ul><ul><li>ASM: </li></ul><ul><li>mov ax, y ;ax=y </li></ul><ul><li>sub ax, z ;ax=ax-z=y-z </li></ul><ul><li>mov x, ax ;x=ax=y-z </li></ul>
  35. 42. INCREMENT (INC) <ul><li>X := X + 1; </li></ul><ul><li>ASM: </li></ul><ul><li>inc x </li></ul>
  36. 43. DECREMENT (DEC) <ul><li>X := X - 1; </li></ul><ul><li>ASM: </li></ul><ul><li>dec x </li></ul>
  37. 44. Instruction Format <ul><li>instruction has opcode + operand (s) </li></ul><ul><ul><ul><ul><li>ADD AX, 2 </li></ul></ul></ul></ul><ul><ul><ul><ul><li>SUB BX, Y </li></ul></ul></ul></ul><ul><ul><ul><ul><li>MOV Z, 1584 </li></ul></ul></ul></ul><ul><ul><ul><ul><li>INC Y </li></ul></ul></ul></ul><ul><li>opcode is ADD, SUB, MOV, INC </li></ul><ul><li>operands are AX, BX, X, Y, 2, 1584 </li></ul>
  38. 45. Arithmetic Expressions <ul><li>Arithmetic expressions, in most high level languages, look similar to their algebraic equivalents: </li></ul><ul><li>X:=Y+Z; </li></ul><ul><li>In assembly language, you’ll need several statements to accomplish this same task, e.g., </li></ul><ul><ul><ul><ul><ul><li>mov ax, y ;ax=y </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>add z ;ax=ax+y=z+y </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>mov x, ax ;x=ax=x+y </li></ul></ul></ul></ul></ul>
  39. 46. Complex Expressions <ul><li>A complex function that is easy to convert to assembly language is one that involves </li></ul><ul><li>three terms and two operators, for example: </li></ul><ul><li>W := W - Y - Z; </li></ul>
  40. 47. Complex Expressions <ul><li>Clearly the straight-forward assembly language conversion of this statement will require two sub instructions. </li></ul><ul><li>However, even with an expression as simple as this one, the conversion is not trivial. </li></ul><ul><li>There are actually two ways to convert this from the statement above into assembly language: </li></ul><ul><li>mov ax, w </li></ul><ul><li>sub ax, y </li></ul><ul><li>sub ax, z </li></ul><ul><li>mov w, ax </li></ul>
  41. 48. Debuggers and Debugging <ul><li>The final, and almost certainly the most painful, part of the assembly language development process is debugging. </li></ul><ul><li>Debugging is simply the systematic process by which bugs are located and corrected. </li></ul><ul><li>A debugger is a utility program designed specifically to help you locate and identify bugs. </li></ul>
  42. 49. Debuggers and Debugging <ul><li>One of the problems with debugging computer programs is that they operate so quickly. </li></ul><ul><li>Thousands of machine instructions can be executed in a single second, and if one of those instructions isn't quite right, it's past and gone long before you can identify which one it is by staring at the screen. </li></ul><ul><li>A debugger allows you to execute the machine instructions in a program one at a time , allowing you to pause indefinitely between each one to examine the effects of the last instruction on the screen. </li></ul><ul><li>The debugger also lets you look at the contents of any location in memory, and the values stored in any register, during that pause between instructions. </li></ul>
  43. 259. Opcode mnemonics <ul><li>Instructions (statements) in assembly language are generally very simple, unlike those in high-level languages. </li></ul><ul><li>Generally, an opcode is a symbolic name for a single executable machine language instruction, and there is at least one opcode mnemonic defined for each machine language instruction. </li></ul><ul><li>Each instruction typically consists of an operation or opcode plus zero or more operands . </li></ul>
  44. 260. Assembly directives / pseudo-ops <ul><li>Assembly Directives are instructions that are executed by the Assembler at assembly time, not by the CPU at run time. </li></ul>
  45. 261. Assembling the Source Code File <ul><li>The text editor first creates a new text file, and later changes that same text file, as you extend, modify, and perfect your assembly language program. </li></ul><ul><li>As a convention, most assembly language source code files are given a file extension of .ASM. </li></ul><ul><li>In other words, for the program named FOO, the assembly language source code file would be named FOO.ASM. </li></ul><ul><li>It is possible to use file extensions other than .ASM, but I feel that using the .ASM extension can eliminate some confusion by allowing you to tell at a glance what a file is for-just by looking at its name. </li></ul><ul><li>All told, about nine different kinds of files can be involved during assembly language development-more if you take the horrendous leap into Windows software development. </li></ul>
  46. 262. Assembling the Source Code File <ul><li>Each type of file will have its own standard file extension. </li></ul><ul><li>Anything that will help you keep all that complexity in line will be worth the (admittedly) rigid confines of a standard naming convention. </li></ul><ul><li>As you can see from the flow in figure above, the editor produces a source code text file, which we show as having the .ASM extension. </li></ul><ul><li>This file is then passed to the assembler program itself, for translation to a re locatable object module file with an extension of .OBJ. </li></ul><ul><li>When you invoke the assembler, DOS will load the assembler from disk and run it. </li></ul>
  47. 263. Assembling the Source Code File <ul><li>The assembler will open the source code file you named after the name of the assembler and begin processing the file. </li></ul><ul><li>Almost immediately afterward, it will create an object file with the same name as the source file, but with an .OBJ extension. </li></ul><ul><li>As the assembler reads lines from the source code file, it will examine them, construct the binary machine instructions the source code lines represent, and then write those machine instructions to the object code file. </li></ul><ul><li>When the assembler comes to the end of the source code file, it will close both source code file and object code file and return control to DOS. </li></ul>
  48. 264. Linking <ul><li>In traditional assembly language work, what actually happens is that the assembler writes an intermediate object code file with an .OBJ extension to disk. </li></ul><ul><li>You can't run this .OBJ file, even though it generally contains all the machine instructions that your assembly language source code file specified. </li></ul><ul><li>The .OBJ file needs to be processed by another translator program, the linker. </li></ul><ul><li>The linker performs a number of operations on the .OBJ file, most of which would be meaningless to you at this point. </li></ul><ul><li>The most obvious task the linker does is to weave several .OBJ files into a single . </li></ul>
  49. 265. Debuggers and Debugging <ul><li>The final, and almost certainly the most painful, part of the assembly language development process is debugging. </li></ul><ul><li>Debugging is simply the systematic process by which bugs are located and corrected. </li></ul><ul><li>A debugger is a utility program designed specifically to help you locate and identify bugs. </li></ul>
  50. 266. Debuggers and Debugging <ul><li>One of the problems with debugging computer programs is that they operate so quickly. </li></ul><ul><li>Thousands of machine instructions can be executed in a single second, and if one of those instructions isn't quite right, it's past and gone long before you can identify which one it is by staring at the screen. </li></ul><ul><li>A debugger allows you to execute the machine instructions in a program one at a time , allowing you to pause indefinitely between each one to examine the effects of the last instruction on the screen. </li></ul><ul><li>The debugger also lets you look at the contents of any location in memory, and the values stored in any register, during that pause between instructions. </li></ul>

×