GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Flussdiagramm

Ohne Titel

Jossy Ivan Mejia Vargas Spanisch

Ohne Titel

Inhalt des Flussdiagramms

  1. Assembly Language

  2. Assembly language programs are created out of three different classes of statements

  3. The first class tell the processor what to do. These statements are called executable instructions, or instructions for short.

  4. The second class of statements provides information to the assembler on various aspects of the assembly process. These instructions are called assembler directives or pseudo-op

  5. The last class of statements , called macros, provide a sophisticated tex t substitution mecha nism. Macros are discussed in detail in the next chapter.

  6. Assembly language statements are entered one per line in the source file. All three classes of the assembly language statements use the same format: [label] mnemoni c [operands ] [/comment

  7. Now let us look at some sample assembly language statements. repeat: in c resul t /incremen t result by 1

  8. The label repeat ca n be used to refer to this particular statement. The mnemonic inc indicates increment operation to be done on the data stored in memory at a location identified by result.

  9. It is a good programming practice to use blank lines and spaces to improve the readability of assembly language programs

  10. In particular, we almost always write labels on a separate line unless doing so destroys the program structure. Thus , our first example assembly language statement is written on two lines as repeat: inc resul t /incremen t result by 1

  11. The NASM assembler provides several directives to reserve space for variables

  12. Assembl y language instructions typically require one or more operands. These operands can be at different locations .

  13. There are several different ways we can specify the location of the operands. These are referred to as the addressing modes

  14. These addressing modes are sufficient to write simple but meaningful assembly language programs

  15. Data Allocation

  16. In high-level languages, allocation of storage space for variables is done indirectly by specifying the data types of each variable used in the program.

  17. For example, in C, the following declarations allocate different amounts of storage space for each variable.

  18. char response; /*allocates 1 bit */

    int value; /*allocates 4 bit */

    float total; /*allocates 4 bit */

    double temp; /*allocates 8 bit */

  19. These variable declarations not only specify the amount of storage required, but also indicate how the stored bit pattern should be interpreted

  20. In the assembly language, allocation of storage space is done by the define assembler directive. The define directive can be used to reserve and initialize one or more bytes.

  21. The general format of the storage allocation statement for initialized data is :

    [variable-name] define-directive initial-value [,initial-value],.....

  22. The square brackets indicate optiona l items . Th e variable-name i s used to identify the storage space allocated. The assembler associates an offset value for each variable name defined in the data segment.

  23. Uninitialized Data

  24. To reserve space for uninitialized data , we use RESB, RESW, and so on. Eac h reserve directive takes a single operand that specifies the number of units of space (bytes, words,...) to be reserved

  25. There is a reserve directive for each define directive.

    RESB Reserve a Byte

    RESW Reserve a Word

    RESD Reserve a Doubleword

    RESQ Reserve a Quadword

    REST Reserve Ten Bytes

  26. Multiple Definitions

  27. Assembly languag e programs typically contain several data definition statements . For example, look at the following assembly language program fragment :

  28. sort DB 'Y' ; ASCII of y = 79H

    value DW 2515 9 ; 25159D = 6247H

    total DD 54280353 5 ; 542803535D = 205A864FH

  29. When several dat a definition statements are used as above , the assembler allocate s contiguous memory for these variables. The memory layout for these three variables is

  30. Ohne Titel
  31. Multiple Initializations

  32. The TIMES directive allows multiple initializations to the same value. Using TIMES, the marks array can be defined as: marks TIMES 8 DW 0

    The TIMES directive is useful in defining arrays and tables.

  33. Symbol Table

  34. When we allocate storage space using a data definition directive, we usually associate a symbolic name to refer to it. The assembler, during the assembly process, assigns an offset value for each symbolic name.

  35. For example, consider the following data definition statements:

  36. .DATA

    value DW 0

    sum DD 0

    marks TIMES 10 DW 0

    message DB 'The grade is:' ,0 charl DB ?

  37. As noted before, the assembler assigns contiguous memory space for the variables. The assembler also uses the same ordering of variables that is present in the source code

  38. Where Are the Operands

  39. Ther e are severa l way s to specify the location of the operands. These are called the addressing modes.

    An operand required by an instruction may be in any one of the following locations:

  40. - in a register internal to the processor;

    -in the instruction itself;

    - in main memory (usually in the data segment);

    -at an I/O port .

  41. Specification o f an operand that is in a register is called register addressing mode, while immediate addressing mode refers to specifying an operand that is part of the instruction. Severa l addressing modes are available to specify the location of an operand residing in memory.

  42. Register Addressing Mode

  43. In this addressing mode, processor's internal registers contain the data to be manipulated by the instruction. For example, the instruction

  44. mov EAX,EB

  45. requires two operands and both are in the processor registers. The syntax of the mov instruction is

  46. mov destination,source

  47. Immediate Addressing Mode

  48. In this addressing mode, data is specified as part of the instruction itself. As a result, even though the data is in memory, it is located in the code segment, not in the data segment.

  49. This addressing mode is typically used in instructions that require at least two data items to manipulate.

  50. The remainder of the addressing modes we discuss here deal with operands that are located in the data segment. These are called the memory addressing modes

  51. Direct Addressing Mode

  52. Operands specified in a memory-addressing mode require access to the main memory, usually to the data segment. A s a result, they tend to be slower than either of the two previous addressing modes.

  53. Recall that to locate a data item in the data segment, we need two components: the segment start address and an offset value within the segment. The start address of the segment is typically found in the DS register. Thus , various memory-addressing modes differ i n the way the offset value of the data is specified. The offset value is often called the effective address

  54. Indirect Addressing Mode

  55. I n this addressing mode , the offse t or

    effective addres s of the data is in one of the general registers . Fo r this reason , this addressing mode is sometimes referred to as the register indirect addressing mode.

  56. The indirect addressing mode is not required for variables having only a single element (e.g., response). Bu t for variables like tablel containin g several elements, the starting address of the data structure can be loaded into, say, the EBX register and then EBX acts as a pointer to an element in tablel. B y manipulating the contents of the EBX register, we can access different elements of table1.

  57. Overview of Assembly Language Instructions

  58. The MOV Instruction

  59. We have already introduced the mov instruction, which requires two operands and has the syntax

    mov destination,source

  60. The data i s copied from source t o destination an d the source operan d remain s un changed. Bot h operands should be of the same size.

  61. Simple Arithmetic Instructions

  62. The instructin se t provides severa l instructions to perform simpl e arithmetic operations .

  63. The INC and DEC Instructions

  64. Thes e instruction s can be used to either incremen t or decrement the operands by one.

  65. The inc (INCrement) instruction adds one to its operand

  66. The dec (DECrement ) instruction subtracts one from its operand

  67. Bot h instructions require a single operand. The operand can be either in a register or in memory. It does not make sense to use an immediate operand such as inc 55 or dec 109 .

  68. The ADD Instruction

  69. Th e add instruction can be used to add two 8, 16 - or 32-bit operands. The syntax is

  70. add destination,source

  71. As with the mov instruction, add can also take the five basic forms depending on how the two operands are specified. The semantics of the add instruction are destination = destination + sourc

  72. The SUB and CMP Instructions

  73. Th e sub (SUBtract) instruction can be used to subtract two 816- or 32-bit numbers. The syntax is sub destination,source

  74. Conditional Execution

  75. The instruction set has several branching and looping instructions to construct programs that require conditional execution.

  76. Unconditional Jump

  77. The unconditional jump instruction jmp, as its name implies , tells the processor that the next instruction to be executed is located at the label that is given as part of the instruction. has the form: jmp label

  78. Conditional Jump

  79. In conditional jump instructions, program execution is transferred to the target instruction only when the specified condition is satisfied. The format is j<cond> labe

  80. TEC,Sede central, Fundamentos de organización de computadoras

    Resumen #8 (Sivarama, caps. 9)

    Jossy Mejia Vargas

    Lunes 30 de octubre, 2 semestre, Esteban Arias Mendéz

Informationen

Beschreibung
Flussdiagramm am Ohne Titel, erstellt von Jossy Ivan Mejia Vargas am 31/10/2017.
Aufrufe
0
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck