¡GoConqr estrena diseño! Cuéntanos qué te parece.

Diagrama de flujo

Sin título

Jossy Ivan Mejia Vargas Español

Contenido del diagrama

  1. Defining Constants

  2. Data Exchange and Translate Instructions

  3. The XCHG Instruction

  4. The xchg instruction exchanges 8-, 16, or 32-bit source and destination operands. The syntax is similar to that of the mov instruction.

  5. xchg EAX,EDX

    xchg [response],CL

    xchg [total],DX

  6. As in the mov instruction, both operands cannot be located in memory. Note that this restriction is applicable to most instructions. Thus,

  7. xchg [response] , [namel ] ; illegal

  8. is invalid. The xchg instruction is convenient because we do not need a third register to hold a temporary value in order to swap two values.

  9. For example, we need three mov instructions

    mov ECX,EAX

    mov EAX,EDX

    mov EDX,ECX

  10. Another instruction , bswap, can be used to perform such conversions on 32-bit data.

    The format is

    bswap register

    This instruction works only on the data located in a 32-bit register.

  11. The XLAT Instruction

  12. The xlat (translate ) instruction can be used to perform character translation. The format of this instruction is shown below: xlatb

  13. To use this instruction , the EBX register must to be loaded with the starting address of the translation table and AL must contain an index value into the table.

  14. The xlat instruction adds contents of AL to EBX and reads the byte at the resulting address.

  15. This byte replaces the index value in the AL register

  16. Shift and Rotate Instructions

  17. Shift Instructions

  18. The instruction set provides several shift instructions . We discuss the following two instructions here: shl (SHif t Left ) and shr (SHif t Right) .

  19. The shl instruction can be used to left shif a destination operand. Each shift to the left by one bit position causes the leftmost bit to move to the carry flag (CF).

  20. The shr instruction works similarly but shifts bits to the right as shown below:

  21. The general formats of these instructions are:

  22. shl destination,count

    shl destination,CL

    shr destination,count

    shr destination,CL

  23. The destination can be an 8-, 16 - or 32-bit operand stored either in a register or in memory.

  24. Rotate Instructions

  25. A drawback with the shift instructions is that the bits shifted out are lost. There may be situations where we want to keep these bits.

  26. The rotate family of instructions provides this facility. These instructions can be divided into two types: rotate without involving the carry flag, or through the carry flag.

  27. Rotate Without Carry

    There are two instructions in this group: rol (Rotat e Left) ror (Rotate Right)

  28. The format of instructions

  29. rol destination,count

    rol destination,CL

    ror destination,count

    ror destination,CL

  30. MACROS

  31. Macros provide a means by which a block of text (code, data, etc.) can be represented by a name (called the macro name)

  32. Whe n the assembler encounters that name later in the program , the block of text associated with the macro name is substituted.

  33. In NASM, macros can be defined with %macro and %endmacro directives . The macro text begins with the %macro directive and ends with the %endmacro directive. The macro definition syntax is

  34. %macro macro_name para_count <macro body>

    %endmacro

  35. The para_count specifie s the number parameters used in the macro. The macro_name i s the name of the macro that, when used later in the program, causes macro expansion. To invoke or call a macro, use the macro_name and supply the necessary parameter values.

  36. Macros with Parameters

  37. The previous macro always multiplies EAX by 16 . B y using parameters, we can generalize this macro to operate on a byte, word, or doubleword located either in a general-purpose register or memory. The modified macro is

  38. %macro mult_by_16 1

    sal %1, 4

    %endmacro

  39. The EQU Directive

  40. The %assign Directive

  41. The %define Directive

  42. The syntax of the EQU directive is: name EQU expression

  43. This directive can be used to define numeric constants like the EQU directive. However, %as s ign allows redefinition. For example, we define

  44. This directive is similar to the #define in C. It can be used to define numeric as well as string constants. For example

Información

Descripción
Diagrama sobre Sin título, creado por Jossy Ivan Mejia Vargas el 31/10/2017.
Visitas
1
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?