Brennan Vincent Brennan Vincent - 3 months ago 19
iOS Question

Repeat bytes in Apple assembly?

Is there a way to repeat the same series of bytes many time in Apple's assembler?

Example use-case: if I want to make an iPhone app with a gigabyte of NOP instructions in some function.

Answer

You can use .fill

.fill 69, 4, 0xfeadface
Generates 69 longs of value 0xfeadface

or .space

ten_ones: .space 10, 1

when dealing with bytes only.

I couldn't find the equivalent of NASM TIMES that would let you repeat even instructions.

You can try to achieve that with recursive macros; I don't have access to Apple assembler, thus I can only sketch a possible macro.
Beware of syntax issues, expressiveness and arguments forwarding when dealing with (supposed) limited languages like that used for macros.

.macro TIMES
.if $0 > 0
    $1 
    var $0-1 $1
.endif
.endmacro

TIMES 100, mov