REP Prefixes
You can put rep in front of an instruction and cause
the instruction to be repeated until cx becomes zero.
There are five versions of this:
- rep
- repe
- repz
- repne
- repnz
rep strop equivalent
| | jcxz | stropDone | |
| stropLoop: | | | |
| | strop | | |
| | loop | stropLoop | |
| stropDone: | | | |
repE/Z strop equivalent
| | jcxz | stropDone | |
| stropLoop: | | | |
| | strop | | |
| | jnz | stropDone | ; jnz = jne |
| | loop | stropLoop | |
| stropDone: | | | |
repNE/NZ strop equivalent
| | jcxz | stropDone | |
| stropLoop: | | | |
| | strop | | |
| | jz | stropDone | ; jz = je |
| | loop | stropLoop | |
| stropDone: | | | |
Example
Let es:di point to an array to 100 bytes. To move a zero into
each element:
| | mov | al, 0 | |
| | cld | | |
| | mov | cx, 100 | |
| | rep | stosb | ; ary[i++] = 0; |
UMBC |
CSEE