Home Random Page


CATEGORIES:

BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism






Syntax of a Macro

The parts which make a macro are:

Declaration of the macro
Code of the macro
Macro termination directive

The declaration of the macro is done the following way:

NameMacro MACRO [parameter1, parameter2...]

Even though we have the functionality of the parameters it is possible to
create a macro which does not need them.

The directive for the termination of the macro is: ENDM

To use a macro it is only necessary to call it by its name, as if it were
another assembler instruction, since directives are no longer necessary as
in the case of the procedures.

Blocks repetitions

The simplest block repetitions REPT (not supported WASM) performs assembling portion of the program specified number of times. For example, if you want to create a byte array initialized values ​​from 0 to 0FFh, this can be done by repeating the DB pseudo-command, as follows:

hexnumber = 0

hextable label byte; name of the array

rept 256, Block start

db hexnumber; These two lines are assembled

hexnumber = hexnumber +1; 256.

endm

Blocks of repetitions, as well as macros can be called with parameters. For this purpose, the directive IRP and IRPC:

irp parameter <value1, value2 ...>

...

endm

 

irpc parameter string

...

endm

Block described the directive IRP, will be called as many times as indicated in the list of values ​​(in angle brackets), and each iteration will be determined by a label with the name of the parameter that is equal to the next value from the list. For example, the next block of repetitions will keep the stack registers AX, BX, CX and DX:

irp reg, <ax,bx,cx,dx>

push reg

endm

Directive IRPC (FORC in WASM) describes a block that is executed as many times as symbols the specified string, and each iteration will be determined by a label with the name of the parameter that is equal to the next character in the string. If the string contains spaces or other characters that are not allowed for the labels, it must be enclosed in angle brackets. For example, the next block is the string in memory, after placing each character in the string attribute 0Fh (white on black background), so that this line can then be copied directly into the video memory.

irpc character, <character string>

db '& character &', 0Fh

endm In this example, the ampersands that option instead of the character had been substituted its value even inside the quotation marks. Ampersand is one of the macro statement - the special operators that act only within the macro blocks and repetitions.

The macro statements or Macrooperators.
The macro statements ampersand (&) is needed to ensure that the parameter that is passed as an operand of macro definitions or block repetitions, substitute value before processing line assembler. For example, the following macro will execute the command PUSH EAX, when called as PUSHREG A:
pushreg macro letter
push e & letter & x
endm
Sometimes it is possible to use only one ampersand at the beginning of the parameter if there is no ambiguity. For example, if the number is transmitted, and the need to create a set of variables with names ending this number:
irp number, <1,2,3,4>
number db?
endm
Macro statement <> (angle brackets) operates so that all the text in the parentheses is treated as a text string, even if it contains spaces or other separators. As we have seen, this macro statement is used to transfer text strings as parameters to the macro. Another frequent use of angle brackets - Transfer list of options embedded macro definitions or block repetitions.
Macro statement! (Exclamation mark) is used similarly to the angle brackets, but only works in one the next character, so if that character is a comma - or angle bracket, it will still be sent as part of a macro parameter.
Macro statement% (percentage) points out that being followed by the text of an expression and must be calculated. This is usually required in order to pass as a parameter to the macro not the expression itself, and its result.



 


Date: 2015-01-29; view: 1099


<== previous page | next page ==>
Attributes of the records MFT. Catalogues in NTFS. | Management of files. Management of listing. Comments. File Management
doclecture.net - lectures - 2014-2024 year. Copyright infringement or personal data (0.008 sec.)