string instructions string instructions were designed to operate on large data structures. the si...
TRANSCRIPT
![Page 1: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/1.jpg)
String Instructions String instructions were designed to
operate on large data structures. The SI and DI registers are used as
pointers to the data structures being accessed or manipulated.
The operation of the dedicated registers stated above are used to simplify code and minimize its size.
![Page 2: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/2.jpg)
String Instructions The registers(DI,SI) are automatically
incremented or decremented depending on the value of the direction flag: DF=0, increment SI, DI. DF=1, decrement SI, DI.
To set or clear the direction flag one should use the following instructions: CLD to clear the DF. STD to set the DF.
![Page 3: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/3.jpg)
String Instructions The REP/REPZ/REPNZ prefixes are
used to repeat the operation it precedes.
String instructions we will discuss: LODS STOS MOVS CMPS SCAS INS OUTS
![Page 4: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/4.jpg)
LODS/LODSB/LODSW/LODSD Loads the AL, AX or EAX registers with
the content of the memory byte, word or double word pointed to by SI relative to DS. After the transfer is made, the SI register is automatically updated as follows: SI is incremented if DF=0. SI is decremented if DF=1.
![Page 5: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/5.jpg)
LODS/LODSB/LODSW/LODSD Examples:
LODSB
AL=DS:[SI]; SI=SI 1 LODSW
AX=DS:[SI]; SI=SI 2 LODSD
EAX=DS:[SI]; SI=SI 4 LODS MEAN
AL=DS:[SI]; SI=SI 1 (if MEAN is a byte) LODS LIST
AX=DS:[SI]; SI=SI 2 (if LIST is a word) LODS MAX
EAX=DS:[SI]; SI=SI 4 (if MAX is a double word)
![Page 6: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/6.jpg)
LODS/LODSB/LODSW/LODSDExample
Assume:Location ContentRegister SI 500HMemory location 500H 'A'Register AL '2'
After execution of LODSB
If DF=0 then:
Location ContentRegister SI 501HMemory location 500H 'A'Register AL 'A'
Else if DF=1 then:
Location ContentRegister SI 4FFHMemory location 500H 'A'Register AL 'A'
![Page 7: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/7.jpg)
STOS/STOSB/STOSW/STOSD Transfers the contents of the AL, AX or
EAX registers to the memory byte, word or double word pointed to by DI relative to ES. After the transfer is made, the DI register is automatically updated as follows: DI is incremented if DF=0. DI is decremented if DF=1.
![Page 8: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/8.jpg)
STOS/STOSB/STOSW/STOSD Examples:
STOSB
ES:[DI]=AL; DI=DI 1 STOSW
ES:[DI]=AX; DI=DI 2 STOSD
ES:[DI]=EAX; DI=DI 4 STOS MEAN
ES:[DI]=AL; DI=DI 1 (if MEAN is a byte) STOS LIST
ES:[DI]=AX; DI=DI 2 (if LIST is a word) STOS MAX
ES:[DI]=EAX; DI=DI 4 (if MAX is a double word)
![Page 9: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/9.jpg)
STOS/STOSB/STOSW/STOSDExampleAssume:
Location ContentRegister DI 500HMemory location 500H 'A'Register AL '2'
After execution of STOSB
If DF=0 then:
Location ContentRegister DI 501HMemory location 500H '2'Register AL '2'
Else if DF=1 then:
Location ContentRegister DI 4FFHMemory location 500H '2'Register AL '2'
![Page 10: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/10.jpg)
MOVS/MOVSB/MOVSW/MOVSD Transfers the contents of the the
memory byte, word or double word pointed to by SI relative to DS to the memory byte, word or double word pointed to by DI relative to ES. After the transfer is made, the DI register is automatically updated as follows: DI is incremented if DF=0. DI is decremented if DF=1.
![Page 11: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/11.jpg)
MOVS/MOVSB/MOVSW/MOVSD Examples:
MOVSBES:[DI]=DS:[SI]; DI=DI 1;SI=SI 1
MOVSWES:[DI]= DS:[SI]; DI=DI 2; SI=SI 2
MOVSDES:[DI]=DS:[SI]; DI=DI 4; SI=SI 4
MOVS MEAN1,MEAN2ES:[DI]=DS:[SI]; DI=DI 1; SI=SI 1 (if MEAN1 and MEAN2 are byte sized)
MOVS LIST1,LIST2ES:[DI]=DS:[SI]; DI=DI 2; SI=SI 2 (if LIST1 and LIST2 are word sized)
MOVS MAX1,MAX2ES:[DI]=DS:[SI]; DI=DI 4; SI=SI 4 (if MAX1 and MAX2 are double word sized)
![Page 12: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/12.jpg)
MOVS/MOVSB/MOVSW/MOVSDExampleAssume:
Location ContentRegister SI 500HRegister DI 600HMemory location 500H '2'Memory location 600H 'W'
After execution of MOVSB
If DF=0 then:
Location ContentRegister SI 501HRegister DI 601HMemory location 500H '2'Memory location 600H '2'
Else if DF=1 then:
Location ContentRegister SI 4FFHRegister DI 5FFHMemory location 500H '2'Memory location 600H '2'
![Page 13: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/13.jpg)
INS/INSB/INSW/INSD Transfer the contents of the port
addressed by DX to the memory byte, word or double word pointed to by DI relative to ES. After the transfer is made, the DI register is automatically updated as follows: DI is incremented if DF=0. DI is decremented if DF=1.
![Page 14: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/14.jpg)
INS/INSB/INSW/INSD Examples:
INSBES:[DI]=[DX]; DI=DI 1
INSWES:[DI]= [DX]; DI=DI 2
INSDES:[DI]=[DX]; DI=DI 4
INS MEANES:[DI]=[DX]; DI=DI 1 (if MEAN is a byte)
INS LISTES:[DI]=[DX]; DI=DI 2 (if LIST is a word)
INS MAXES:[DI]=[DX]; DI=DI 4 (if MAX is a double word)
![Page 15: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/15.jpg)
OUTS/OUTSB/OUTSW/OUTSD Transfer the contents of the memory byte,
word or double word pointed to by SI relative to DS to the port addressed by DX. After the transfer is made, the SI register is automatically updated as follows: SI is incremented if DF=0. SI is decremented if DF=1
![Page 16: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/16.jpg)
OUTS/OUTSB/OUTSW/OUTSD Examples:
OUTSB[DX]=DS:[SI]; SI=SI 1
OUTSW[DX]= DS:[SI]; SI=SI 2
OUTSD[DX]=DS:[SI]; SI=SI 4
OUTS MEAN[DX]=DS:[SI]; SI=SI 1 (if MEAN is a byte)
OUTS LIST[DX]=DS:[SI]; SI=SI 2 (if LIST is a word)
OUTS MAX[DX]=DS:[SI]; SI=SI 4 (if MAX is a double word)
![Page 17: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/17.jpg)
CMPS/CMPSB/CMPSW/CMPSD Compares the contents of the the memory
byte, word or double word pointed to by SI relative to DS to the memory byte, word or double word pointed to by DI relative to ES and changes the flags accordingly. After the comparison is made, the DI and SI registers are automatically updated as follows: DI and SI are incremented if DF=0. DI and SI are decremented if DF=1.
![Page 18: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/18.jpg)
SCAS/SCASB/SCASW/SCASD Compares the contents of the AL, AX or
EAX register with the memory byte, word or double word pointed to by DI relative to ES and changes the flags accordingly. After the comparison is made, the DI register is automatically updated as follows: DI is incremented if DF=0. DI is decremented if DF=1.
![Page 19: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/19.jpg)
REP/REPZ/REPNZ These prefixes cause the string
instruction that follows them to be repeated the number of times in the count register ECX or until: ZF=0 in the case of REPZ (repeat while
equal). ZF=1 in the case of REPNZ (repeat while
not equal).
![Page 20: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/20.jpg)
REP/REPZ/REPNZ Use REPNE and SCASB to search for
the character ‘f’ in the buffer given below.
BUFFER DB ‘EE3751’ MOV AL,’f’ LEA DI,BUFFER MOV ECX,6 CLD REPNE SCASB JE FOUND
![Page 21: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/21.jpg)
REP/REPZ/REPNZ Use REPNE and SCASB to search for
the character ‘3’ in the buffer given below.
BUFFER DB ‘EE3751’ MOV AL,’f’ LEA DI,BUFFER MOV ECX,6 CLD REPNE SCASB JE FOUND
![Page 22: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/22.jpg)
Modular Programming Many programs are too large to be
developed by a single individual. A team of programmers develops different
parts of the system and their program modules are linked together, thus becoming a large program which includes all modules programmed separately.
![Page 23: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/23.jpg)
The Assembler and Linker
The Assembler converts an ASCII source file created by the programmer into hexadecimal object file. TASM PROG1.ASM
The Linker reads the object file and creates the executable file. TLINK PROG1.OBJ
![Page 24: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/24.jpg)
PUBLIC and EXTERN These two directives allow the
programmer to define labels, data, and entire segments as follows: PUBLIC defines that labels, data, and entire
segments are available for other program modules to use. .DATA
PUBLIC LIST
LIST DB 50 DUP(?) .
![Page 25: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/25.jpg)
PUBLIC and EXTERN
EXTERN declares that labels are external to a module. If data is defined as external, their sizes must be defined. .DATA
Extrn LIST:byte .CODE
Extrn POWER:far
![Page 26: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/26.jpg)
Libraries
Collections of procedures that may be used by many different programs.
![Page 27: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/27.jpg)
DOS and BIOS Interrupts DOS and BIOS interrupts are used to
perform some very useful functions, such as displaying data to the monitor, reading data from keyboard, etc.
They are used by identifying the interrupt option type, which is the value stored in register AH and providing, whatever extra information that the specific option requires.
![Page 28: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/28.jpg)
BIOS Interrupt 10H Option 0H – Sets video mode. Registers used:
AH = 0H AL = Video Mode.
3H - CGA Color text of 80X25 7H - Monochrome text of 80X25
Ex: MOV AH,0 MOV AL,7 INT 10H
![Page 29: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/29.jpg)
BIOS Interrupt 10H Option 2H – Sets the cursor to a
specific location. Registers used:
AH = 2H BH = 0H selects Page 0. DH = Row position. DL = Column position.
Ex: MOV AH,2 MOV BH,0 MOV DH,12 MOV DL,39 INT 10H
![Page 30: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/30.jpg)
BIOS Interrupt 10H Option 6H – Scroll window up. This
interrupt is also used to clear the screen when you set AL = 0.
Registers used: AH = 6H AL = number of lines to scroll. BH = display attribute. CH = y coordinate of top left. CL = x coordinate of top left. DH = y coordinate of lower right. DL = x coordinate of lower right.
![Page 31: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/31.jpg)
BIOS Interrupt 10H Clear Screen Example:
MOV AH,6 MOV AL,0 MOV BH,7 MOV CH,0 MOV CL,0 MOV DH,24 MOV DL,79 INT 10H
The code above may be shortened by using AX, BX and DX registers to move word size data instead of byte size data.
![Page 32: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/32.jpg)
BIOS Interrupt 10H Option 7H – Scroll window down. This
interrupt is also used to clear the screen when you set AL = 0.
Registers used: AH = 7H AL = number of lines to scroll. BH = display attribute. CH = y coordinate of top left. CL = x coordinate of top left. DH = y coordinate of lower right. DL = x coordinate of lower right.
![Page 33: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/33.jpg)
BIOS Interrupt 10H Option 8H – Read a character and its
attribute at the cursor position. Registers used:
AH = 8H and returned attribute value. AL = Returned ASCII value. BH = display page.
![Page 34: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/34.jpg)
BIOS Interrupt 10H Option 9H – Write a character and its
attribute at the cursor position. Registers used:
AH = 9H. AL = ASCII value. BH = display page. BL = attribute. CX = number of characters to write.
![Page 35: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/35.jpg)
Attribute Definition
Monochrome display attributes Blinking
D7 = 0 - Non-blinking D7 = 1 - Blinking
Intensity D3=0 - Normal intensity D3=1 - Highlighted intensity
Background and foreground D6 D5 D4 and D2 D1 D0
White = 0 0 0 Black = 1 1 1
Blinking IntensityD7 D6 D5 D4 D3 D2 D1 D0
Background Foreground
![Page 36: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/36.jpg)
Attribute Definition
Color display attributes Blinking
D7 = 0 - Non-blinking D7 = 1 - Blinking
Intensity D3=0 - Normal intensity D3=1 - Highlighted
intensity Background and
foreground D6 D5 D4 and D2 D1 D0
RGB values defined by the table to the right.
R G B R G BD7 D6 D5 D4 D3 D2 D1 D0
BlinkingBackground
IntensityForeground
I R G B Color0 0 0 0 Black0 0 0 1 Blue0 0 1 0 Green0 0 1 1 Cyan0 1 0 0 Red0 1 0 1 Magenta0 1 1 0 Brown0 1 1 1 White1 0 0 0 Gray1 0 0 1 Light blue1 0 1 0 Light green1 0 1 1 Light cyan1 1 0 0 Light red1 1 0 1 Light magenta1 1 1 0 Ye llow1 1 1 1 High intensity white
![Page 37: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/37.jpg)
DOS Interrupt 21H Option 1 – Inputs a single character
from keyboard and echoes it to the monitor.
Registers used: AH = 1 AL = the character inputted from keyboard.
Ex: MOV AH,1 INT 21H
![Page 38: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/38.jpg)
DOS Interrupt 21H Option 2 – Outputs a single character to
the monitor. Registers used:
AH = 2 DL = the character to be displayed.
Ex: MOV AH,2 MOV DL,’A’ INT 21H
![Page 39: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/39.jpg)
DOS Interrupt 21H Option 6 – Inputs a single character
from keyboard without an echo to the monitor.
Registers used: AH = 6 AL = the character inputted from keyboard. DL = 0FFH or -1
Ex: MOV AH,6 MOV DL,-1 INT 21H
![Page 40: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/40.jpg)
DOS Interrupt 21H Option 9 – Outputs a string of data,
terminated by a $ to the monitor. Registers used:
AH = 9 DX = the offset address of the data to be
displayed. Ex:
MOV AH,09 MOV DX,OFFSET MESS1 INT 21H
![Page 41: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/41.jpg)
DOS Interrupt 21H Option 0AH – Inputs a string of data from the
keyboard. Registers used:
AH = 9 DX = the offset address of the location where string
will be stored. DOS requires that a buffer be defined in the
data segment. It should be defined as follows: 1st byte contains the size of the buffer. 2nd byte is used by DOS to store the number
of bytes stored.
![Page 42: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/42.jpg)
DOS Interrupt 21H Ex:
.DATA BUFFER1 DB 0FH,?,0FH DUP (0FFH) . . MOV AH,0AH MOV DX,OFFSET BUFFER1 INT 21H
Assume “Go Tigers!” was entered on the keyboard. BUFFER1 = 0FH,0BH,’Go Tigers!’,CR,0FFH, 0FFH, 0FFH, 0FFH
![Page 43: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/43.jpg)
DOS Interrupt 21H Option 4CH – Terminates a process, by
returning control to a parent process or to DOS.
Registers used: AH = 4CH AL = binary return code.
Ex: MOV AH,4CH INT 21H
![Page 44: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/44.jpg)
Macros Format
Name MACRO Argument,Argument Macro code
ENDM Example
Power MACRO X,N
![Page 45: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/45.jpg)
Macros SWAP MACRO X,Y PUSH AX PUSH DX MOV AX,X MOV DX,Y MOV Y,AX MOV X,DX POP DX POP AX ENDM
SWAP VAR1,VAR2 PUSH AX PUSH DX MOV AX,VAR1 MOV DX,VAR2 MOV VAR2,AX MOV VAR1,DX MOP DX POP AX
![Page 46: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures](https://reader035.vdocuments.us/reader035/viewer/2022062805/5697bfe11a28abf838cb3eaa/html5/thumbnails/46.jpg)
Macros A local variable is a variable that appears
only in the macro. Local variables need to be defined with
the local directive. Example:
DELAY MACRO COUNT LOCAL AGAIN PUSH CX MOV CX,COUNT AGAIN:LOOP AGAIN POP CX