netspooky/xx

Add support for repetition operator

polprog opened this issue · 1 comments

The way I see it there is no way to pad a structure with a large amount of repeated bytes.
I propose to add a * operator that would repeat the line content n times.
To simplify parsing the operator could only be valid at functional EOL (EOL or before comment), the aim of it is not to make this a compressed file format but rather avoid typing and cluttering the screen

For example to padd with 128 zeros:

0x00*128 -- Foobar structure padding => 0x00 repeated 128 times

or pad with some dwords

$7f 0x12 \x34 56h *0x3F --Baz baz stack paint => 0x7f123456 repeated 63 times

Application example


-- FAT boot sector
eb3c90           | Jump to bootcode
"MSDOS5.0"       | OEM name
0x00*25          | bios param block
0x00*26          | extended bios param block
 ----------------
| boot code     |
 ---------------

0x90 *447   -- NOP padding --
                             |
            -----------------
           |
0xcc        --> INT3

/* M A G I C K */
55aa

PR #12 indirectly implements this and more features.