![]() CATEGORIES: BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism |
Syntax of a MacroThe parts which make a macro are: Declaration of the macro 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 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 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.
Date: 2015-01-29; view: 1369
|