Rate This Document
Findability
Accuracy
Completeness
Readability

Replacing the x86 rep Assembly Instruction

Symptom

Compilation error: unknown mnemonic 'rep' -- 'rep'

Possible Cause

rep is the repeatedly executed instruction of x86 and needs to be replaced with the rept instruction of Arm64.

Solution

The modification method is as follows:

Code on x86:

#define nop __asm__ __volatile__("rep;nop": : :"memory")

This example shows TaiShan implementation. It implements an empty instruction. n indicates the number of cycles.

#define __nops(n) ".rept " #n "\nnop\n.endr\n" 
#define nops(n) asm volatile(__nops(n))