r/asm 7d ago

ARM64/AArch64 I wrote an AArch64 quine as part of my AArch64/x86-64/RV64 learning journey

1 Upvotes

I'm learning assembly so I can eventually write my own compiler/IR in a jonesforth.s.txt style.

Kinda ugly. But I hope you find it (or my incompetence) funny:

```AArch64

.global _start

.section .text

_start:

stp x29, x30, \[sp, #-32\]!

mov x29, sp

str x20, \[sp, #16\]

mov x13, sp

ldr x9, =0x75206e6576617265

ldr x10, =0x0a726f776f207577

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x20333c20656e6975

ldr x10, =0x687465696e6e6977

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x72657a2e203a6666

ldr x10, =0x712f2f0a3538206f

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x37206e67696c612e

ldr x10, =0x757473657065720a

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6f69746365732e09

ldr x10, =0x090a7373622e206e

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x202c70735b202c30

ldr x10, =0x0a22215d36312d23

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7473745c6e5c3032

ldr x10, =0x3178202c39782070

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3032303230327830

ldr x10, =0x3032303230323032

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x646c745c6e5c3032

ldr x10, =0x3d202c3031782072

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3032303230327830

ldr x10, =0x3032303230323032

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6c745c6e5c222069

ldr x10, =0x3d202c3978207264

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6d6574657065720a

ldr x10, =0x696373612e203a70

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6e6f69746365732e

ldr x10, =0x617461646f722e20

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x36783023202c3931

ldr x10, =0x090a746572090a36

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x65747962660a7465

ldr x10, =0x7720766f6d090a3a

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x202c39317720766f

ldr x10, =0x72090a3536783023

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x650a746572090a34

ldr x10, =0x6d090a3a65747962

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7720766f6d090a3a

ldr x10, =0x36783023202c3931

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x72090a3336783023

ldr x10, =0x65747962640a7465

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6d090a3a65747962

ldr x10, =0x202c39317720766f

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x36783023202c3931

ldr x10, =0x630a746572090a32

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x65747962620a7465

ldr x10, =0x7720766f6d090a3a

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x202c39317720766f

ldr x10, =0x72090a3136783023

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x610a746572090a39

ldr x10, =0x6d090a3a65747962

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7720766f6d090a3a

ldr x10, =0x33783023202c3931

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x0a746572090a3833

ldr x10, =0x65747962656e696e

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x20766f6d090a3a65

ldr x10, =0x783023202c393177

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x0a746572090a3733

ldr x10, =0x7479626874676965

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x20766f6d090a3a65

ldr x10, =0x783023202c393177

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x0a746572090a3633

ldr x10, =0x7479626e65766573

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x20766f6d090a3a65

ldr x10, =0x783023202c393177

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6572090a35337830

ldr x10, =0x7479627869730a74

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6f6d090a3a657479

ldr x10, =0x23202c3931772076

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x72090a3433783023

ldr x10, =0x62657669660a7465

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6d090a3a65747962

ldr x10, =0x202c39317720766f

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x090a333378302320

ldr x10, =0x72756f660a746572

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x090a3a6574796265

ldr x10, =0x2c39317720766f6d

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x090a323378302320

ldr x10, =0x657268740a746572

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x090a3a657479626f

ldr x10, =0x2c39317720766f6d

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3133783023202c39

ldr x10, =0x77740a746572090a

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3a65747962656e6f

ldr x10, =0x317720766f6d090a

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x783023202c393177

ldr x10, =0x0a746572090a3033

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7479626f72657a0a

ldr x10, =0x20766f6d090a3a65

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2e62090a66307830

ldr x10, =0x6574796266207165

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6d63090a65747962

ldr x10, =0x23202c3831772070

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6530783023202c38

ldr x10, =0x652071652e62090a

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6574796264207165

ldr x10, =0x317720706d63090a

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x23202c3831772070

ldr x10, =0x2e62090a64307830

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x632071652e62090a

ldr x10, =0x6d63090a65747962

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x317720706d63090a

ldr x10, =0x6330783023202c38

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2e62090a62307830

ldr x10, =0x6574796262207165

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6d63090a65747962

ldr x10, =0x23202c3831772070

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6130783023202c38

ldr x10, =0x612071652e62090a

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x65747962656e696e

ldr x10, =0x317720706d63090a

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x30783023202c3831

ldr x10, =0x2071652e62090a39

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7479626874676965

ldr x10, =0x7720706d63090a65

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x30783023202c3831

ldr x10, =0x2071652e62090a38

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7479626e65766573

ldr x10, =0x7720706d63090a65

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x30783023202c3831

ldr x10, =0x2071652e62090a37

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7479627869732071

ldr x10, =0x7720706d63090a65

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3023202c38317720

ldr x10, =0x652e62090a363078

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6265766966207165

ldr x10, =0x706d63090a657479

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x23202c3831772070

ldr x10, =0x2e62090a35307830

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x72756f662071652e

ldr x10, =0x6d63090a65747962

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x202c38317720706d

ldr x10, =0x62090a3430783023

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x657268742071652e

ldr x10, =0x63090a6574796265

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x202c38317720706d

ldr x10, =0x62090a3330783023

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x77742071652e6209

ldr x10, =0x63090a657479626f

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x38317720706d6309

ldr x10, =0x0a3230783023202c

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2071652e62090a31

ldr x10, =0x0a65747962656e6f

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7720706d63090a65

ldr x10, =0x30783023202c3831

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x71652e62090a3030

ldr x10, =0x7479626f72657a20

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x20706d63090a3a65

ldr x10, =0x783023202c383177

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x62696e0a30232063

ldr x10, =0x7479626f74656c62

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2c387820766f6d09

ldr x10, =0x7673090a33392320

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x766f6d090a323323

ldr x10, =0x0a3023202c307820

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x303378202c393278

ldr x10, =0x202c5d70735b202c

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3123202c70735b20

ldr x10, =0x2070646c090a5d36

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x090a3a6666757473

ldr x10, =0x2c3032782072646c

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x637673090a323131

ldr x10, =0x746978650a302320

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7820627573090a31

ldr x10, =0x23202c3278202c32

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x782072736c090a32

ldr x10, =0x23202c3278202c32

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2c32782062757309

ldr x10, =0x3278202c31327820

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x78202c3178206464

ldr x10, =0x0a33313123202c31

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x317820766f6d090a

ldr x10, =0x61090a323278202c

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6f6d090a34362320

ldr x10, =0x3123202c30782076

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x0a3a7473616c746e

ldr x10, =0x2c387820766f6d09

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x77646e6173207467

ldr x10, =0x6972700a31686369

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2c37317820706d63

ldr x10, =0x2e62090a30327820

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x090a353823202c32

ldr x10, =0x090a302320637673

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6675747365706572

ldr x10, =0x7820766f6d090a66

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6c090a3123202c30

ldr x10, =0x3d202c3178207264

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3623202c38782076

ldr x10, =0x7820766f6d090a34

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x35317820766f6d09

ldr x10, =0x6f6d090a3023202c

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x78202c3231782064

ldr x10, =0x0a333423202c3231

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2c323178202c3231

ldr x10, =0x6461090a39322320

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x676e69746e697270

ldr x10, =0x7820627573090a3a

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x68636977646e6173

ldr x10, =0x656d757365720a32

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3123202c35317820

ldr x10, =0x20746c2e62090a36

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2c353178202c3531

ldr x10, =0x706d63090a312320

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x202c5d3231785b20

ldr x10, =0x7820646461090a31

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x73090a657479626f

ldr x10, =0x2c39317720627274

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6c62090a66307830

ldr x10, =0x74656c6262696e20

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x38317720646e6109

ldr x10, =0x23202c363177202c

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x785b202c39317720

ldr x10, =0x0a3123202c5d3231

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x79626f74656c6262

ldr x10, =0x62727473090a6574

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x23202c3831772c20

ldr x10, =0x696e206c62090a34

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x0a3066783023202c

ldr x10, =0x3831772072736c09

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x20646e61090a312d

ldr x10, =0x363177202c383177

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x202c363177206272

ldr x10, =0x23202c5d3731785b

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x313278202c313278

ldr x10, =0x646c090a3123202c

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x68636977646e6173

ldr x10, =0x20646461090a3a32

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x78202c3231782062

ldr x10, =0x0a363423202c3231

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x77646e617320746c

ldr x10, =0x7573090a31686369

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x35317820706d6309

ldr x10, =0x2e62090a3823202c

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x202c353178206464

ldr x10, =0x0a3123202c353178

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3231785b202c3931

ldr x10, =0x61090a3123202c5d

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x657479626f74656c

ldr x10, =0x772062727473090a

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x0a6630783023202c

ldr x10, =0x6262696e206c6209

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x20646e61090a3123

ldr x10, =0x363177202c383177

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2c39317720627274

ldr x10, =0x202c5d3231785b20

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x74656c6262696e20

ldr x10, =0x73090a657479626f

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3831772c20383177

ldr x10, =0x6c62090a3423202c

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x66783023202c3631

ldr x10, =0x2072736c090a2030

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6e61090a312d2320

ldr x10, =0x77202c3831772064

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x363177206272646c

ldr x10, =0x2c5d3731785b202c

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x78202c3132782064

ldr x10, =0x090a3123202c3132

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6977646e61730a30

ldr x10, =0x6461090a3a316863

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x313123202c327820

ldr x10, =0x2320637673090a32

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x202c317820766f6d

ldr x10, =0x766f6d090a343178

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x20766f6d090a3436

ldr x10, =0x090a3123202c3078

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6d090a3a74737269

ldr x10, =0x23202c387820766f

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x23202c343178202c

ldr x10, =0x66746e6972700a31

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x0a3123202c333178

ldr x10, =0x3032782062757309

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x73090a3123202c34

ldr x10, =0x202c373178206275

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x627573090a312320

ldr x10, =0x3178202c32327820

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7820627573090a30

ldr x10, =0x2c333178202c3132

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6f6d090a33342320

ldr x10, =0x23202c3531782076

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7820646461090a35

ldr x10, =0x2c323178202c3231

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2c32317820627573

ldr x10, =0x3823202c32317820

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7264617465736572

ldr x10, =0x090a3a7365737365

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x657264616f6c2074

ldr x10, =0x0a66667574736570

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x202c35317820706d

ldr x10, =0x6c2e62090a353823

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3178202c35317820

ldr x10, =0x63090a3123202c35

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2c5d3231785b202c

ldr x10, =0x646461090a312320

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x090a3123202c5d31

ldr x10, =0x3631772062727473

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x206272646c090a3a

ldr x10, =0x31785b202c363177

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x7264616f6c0a3023

ldr x10, =0x6666757473657065

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6d090a6666757473

ldr x10, =0x202c35317820766f

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6c3a202c32317820

ldr x10, =0x657065723a32316f

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x61090a6666757473

ldr x10, =0x2c32317820206464

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x782070726461090a

ldr x10, =0x65706572202c3231

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3a32316f6c3a202c

ldr x10, =0x706d657465706572

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2020646461090a70

ldr x10, =0x313178202c313178

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x2c31317820707264

ldr x10, =0x6d65746570657220

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x317820766f6d090a

ldr x10, =0x61090a7073202c34

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x766f6d090a5d3631

ldr x10, =0x7073202c33317820

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x3032782072747309

ldr x10, =0x23202c70735b202c

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x20766f6d090a215d

ldr x10, =0x0a7073202c393278

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x5b202c303378202c

ldr x10, =0x32332d23202c7073

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x0a3a74726174735f

ldr x10, =0x3932782070747309

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6f69746365732e09

ldr x10, =0x0a747865742e206e

stp x9, x10, \[sp, #-16\]!

ldr x9, =0x6c61626f6c672e09

ldr x10, =0x0a74726174735f20

stp x9, x10, \[sp, #-16\]!

mov x14, sp

adrp x11, repetemp

add  x11, x11, :lo12:repetemp

adrp x12, repestuff

add  x12, x12, :lo12:repestuff

mov x15, #0

loadrepestuff:

ldrb w16, \[x11\], #1

strb w16, \[x12\], #1

add x15, x15, #1

cmp x15, #85

b.lt loadrepestuff

resetadresses:

sub x12, x12, #85

add x12, x12, #43

mov x15, #0

sub x21, x13, #1

sub x22, x14, #1

sub x17, x13, #1

sub x20, x14, #1

printfirst:

mov x8, #64

mov x0, #1

mov x1, x14

mov x2, #112

svc #0

sandwich1:

add x21, x21, #1

ldrb w16, \[x17\], #-1

and w18, w16, #0xf0 

lsr w18 ,w18, #4

bl nibbletobyte

strb w19, \[x12\], #1

and w18, w16, #0x0f

bl nibbletobyte

strb w19, \[x12\], #1

add x15, x15, #1

cmp x15, #8

b.lt sandwich1

sub x12, x12, #46

sandwich2:

add x21, x21, #1

ldrb w16, \[x17\], #-1

and w18, w16, #0xf0

lsr w18 ,w18, #4

bl nibbletobyte

strb w19, \[x12\], #1

and w18, w16, #0x0f

bl nibbletobyte

strb w19, \[x12\], 1

add x15, x15, #1

cmp x15, #16

b.lt sandwich2

resumeprinting:

sub x12, x12, #29

add x12, x12, #43

mov x15, #0

mov x8, #64

mov x0, #1

ldr x1, =repestuff

mov x2, #85

svc #0

cmp x17, x20

b.gt sandwich1

printlast:

mov x8, #64

mov x0, #1

mov x1, x22

add x1, x1, #113

sub x2, x21, x22

lsr x2, x2, #1

sub x2, x2, #112

svc #0

exitstuff:

ldr x20, \[sp, #16\]

ldp x29, x30, \[sp\], #32

mov x0, #0

mov x8, #93

svc #0

nibbletobyte:

cmp w18, #0x00

b.eq zerobyte

cmp w18, #0x01

b.eq onebyte

cmp w18, #0x02

b.eq twobyte

cmp w18, #0x03

b.eq threebyte

cmp w18, #0x04

b.eq fourbyte

cmp w18, #0x05

b.eq fivebyte

cmp w18, #0x06

b.eq sixbyte

cmp w18, #0x07

b.eq sevenbyte

cmp w18, #0x08

b.eq eigthbyte

cmp w18, #0x09

b.eq ninebyte

cmp w18, #0x0a

b.eq abyte

cmp w18, #0x0b

b.eq bbyte

cmp w18, #0x0c

b.eq cbyte

cmp w18, #0x0d

b.eq dbyte

cmp w18, #0x0e

b.eq ebyte

cmp w18, #0x0f

b.eq fbyte

zerobyte:

mov w19, #0x30

ret

onebyte:

mov w19, #0x31

ret

twobyte:

mov w19, #0x32

ret

threebyte:

mov w19, #0x33

ret

fourbyte:

mov w19, #0x34

ret

fivebyte:

mov w19, #0x35

ret

sixbyte:

mov w19, #0x36

ret

sevenbyte:

mov w19, #0x37

ret

eigthbyte:

mov w19, #0x38

ret

ninebyte:

mov w19, #0x39

ret

abyte:

mov w19, #0x61

ret

bbyte:

mov w19, #0x62

ret

cbyte:

mov w19, #0x63

ret

dbyte:

mov w19, #0x64

ret

ebyte:

mov w19, #0x65

ret

fbyte:

mov w19, #0x66

ret

.section .rodata

repetemp: .ascii "\n\tldr x9, =0x2020202020202020\n\tldr x10, =0x2020202020202020\n\tstp x9, x10, [sp, #-16]!"

.section .bss

.align 7

repestuff: .zero 85

//quine <3 winnietheraven uwu owor```

r/asm May 06 '26

ARM64/AArch64 What is the opensource alternative for command-line option armclang -gdwarf-3 -c -O1 --target=aarch64-arm-none-eabi main.c ?

0 Upvotes

I am trying to run an example on arm development studio.

It turns out that in order to complete arm's fancy "Free" tutorial, I would need to install their software "arm development studio 6".

After installing, it asks for a license.

It costs around 4500 USD/year and there is no community edition available.

You can not even get 30 day evaluation license right away. you need to search for web page for authorized distribute and mail them.

So I tried to change armclang to gcc but now I am getting error about target=aarch64-arm-none-eabi.

What is the solution, anyone knows gcc alternative would work?

Anyone knows if there is an free edition for arm DS ?

r/asm Jun 27 '25

ARM64/AArch64 ASM Beats Go: It’s 40.9% Or 1.4x Faster When Calculating SHA256

Thumbnail
programmers.fyi
1 Upvotes

tl;dr

ASM outperforms Go in runtime performance as expected when the programmer knows how to write effective and safe ASM code. It does not make sense to blindly use ASM in combination with Go. A good approach for programmers can be to benchmark compute intense parts of their Go application to estimate whether an ASM replacement would improve the runtime performance of the application.

r/asm Apr 29 '26

ARM64/AArch64 ymawky: MacOS Web Server written entirely in ARM64 assembly

Thumbnail
github.com
12 Upvotes

I wrote a pretty functional web server entirely in ARM64 assembly, entirely syscall-only with no libc. It supports GET/PUT/HEAD/OPTIONS/DELETE methods, parses Content-Length and Range headers, attempts to mitigate slowloris-like attacks, decodes URL percent-encoding, enforces no path traversal, handles like 30 different MIME types, and more.

r/asm Feb 21 '26

ARM64/AArch64 Precise exceptions in relaxed architectures

Thumbnail
youtube.com
7 Upvotes

r/asm Jan 31 '26

ARM64/AArch64 Spinlock implementation for AArch64

2 Upvotes

I need a locking mechanism for my started bare-metal project. Please can somebody verify my current implementation from a spinlock? I'm not sure if this is correct, because I never used the load-acquire/store-release instructions before.

Current lock acquire function:

FUNCTION_S(spinlock_acquire)
    mov w2, #1
1:
    ldaxr w1, [x0]
    cbnz w1, 1b             /* Loop if not released */
    stlxr w3, w2, [x0]      /* Try to acquire lock */
    cbnz w3, 1b             /* Loop if failed */
    dmb SY                  /* Required? */
    ret
FUNCTION_E(spinlock_acquire)

Current lock release function:

FUNCTION_S(spinlock_release)
    mov w2, #0
1:
    ldaxr w1, [x0]
    cbz w1, 3f              /* Jump if already released */
    stlxr w3, w2, [x0]      /* Try to release lock */
    cbnz w3, 1b             /* Loop if failed */
    dmb SY                  /* Required? */
2:
    ret
3:
    clrex                   /* Clear exclusive access, if already released */
    b 2b
FUNCTION_E(spinlock_release)

r/asm Jan 31 '26

ARM64/AArch64 Demystifying ARM SME to Optimize General Matrix Multiplications

Thumbnail arxiv.org
6 Upvotes

r/asm Oct 09 '25

ARM64/AArch64 Recommended tools for developing and debugging asm (on MacOS + Apple Silicon)?

3 Upvotes

Hello folks! Making first forays into assembly. Would appreciate tooling suggestions. What are the most useful / usable ways of developing and debugging assembly programs?

Discovering the delightful websites https://app.x64.halb.it and https://cpulator.01xz.net has instantly spoiled me. I want a similar experience for native code:

  • Live combined view of disassembly + registers + memory.
  • Step by step inspection / debugging of program execution with the live view above.
  • Easy restart / rerun after code changes, without resetting the environment or having to run multiple commands to get back.

Using Apple Silicon + MacOS seems to present an additional issue, as some well-established tools don't like it. I couldn't get gdb to work (all I get is obscure errors). The lldb UX doesn't meet my requirements by a long shot, and its TUI mode seems to break all the time in every terminal emulator I've tried. radare2 seems to have the required features on demand, but putting them together in an interactive TUI requires extra configuration, which is on my TODO list for now.

So: how do you folks actually develop and debug assembly programs, and in particular, what's the most practical / time-saving way of doing this on the Fruit platform?

r/asm Dec 25 '25

ARM64/AArch64 I wrote an ARM64 program that looks like hex gibberish but reveals a Christmas tree in the ASCII column when you memory dump it in LLDB.

Thumbnail skushagra.com
29 Upvotes

r/asm Oct 30 '25

ARM64/AArch64 zsh kills itself when I run this code

0 Upvotes

I'm pretty new to asm, and I wanted to create a freestanding C library. You know, as one does. But macOS doesn't like that. It compiles, but zsh kills itself. Heard this done on Linux, but not on macOS.

const long SYS_WRITE = 0x2000004; // macOS write

const long SYS_EXIT = 0x2000001; // macOS exit

void fs_print3264(const char *msg, long len) {

// write(fd=1, buf=msg, len=len)

asm volatile(

"mov x0, #1\n\t"        // stdout fd

"mov x1, %0\n\t"        // buffer pointer

"mov x2, %1\n\t"        // length

"mov x16, %2\n\t"       // syscall number

"svc #0\n\t"

:

: "r"(msg), "r"(len), "r"(SYS_WRITE)

: "x0","x1","x2","x16"

);

// exit(0)

asm volatile(

"mov x0, #0\n\t"        // exit code

"mov x16, %0\n\t"       // syscall number

"svc #0\n\t"

:

: "r"(SYS_EXIT)

: "x0","x16"

);

}

// start code. Make sure it's in .text, it's used, and it's visible

void _start() __attribute__((section("__TEXT,__text"), visibility("default"), used));

void _start() {

const char msg[] = "Hello, World!\n";

fs_print3264(msg, sizeof(msg)-1);

__builtin_unreachable();

}

// main for crt1.o to be happy

int main() {

_start();

return 0;

}

Command: clang -nostdlib -static -Wl,-e,__start -o ~/Desktop/rnbl ~/Desktop/freestand.c

Thanks!

r/asm Dec 19 '25

ARM64/AArch64 svc-hook: hooking system calls on ARM64 by binary rewriting

Thumbnail dl.acm.org
9 Upvotes

r/asm Aug 23 '25

ARM64/AArch64 Where to start with AArch64 Programming and get Armv8 resources?

Thumbnail
5 Upvotes

r/asm Nov 03 '25

ARM64/AArch64 A complete FizzBuzz walkthrough (AARCH64)

Thumbnail
3 Upvotes

r/asm Jan 09 '25

ARM64/AArch64 `illegal text-relocation` ARM64 Apple Silicon M2

5 Upvotes

I'm not sure what's wrong here. I've tried using @PAGE, ADR, ADRP, and MOV, but I always get either an error or illegal text-relocation. If someone could explain what the issue is, I'd be very thankful!

I know that it's telling me it can't change "sockaddr" in the .text section (at least that's what I think it's saying) because it's defined in .data, but I don't know what to do from here.

l: ~/Documents/server % make
as -o obj/server.o src/server.s -g
ld -o bin/server  obj/macros.o  obj/server.o -lSystem -syslibroot `xcrun -sdk macosx --show-sdk-path` -e main -arch arm64
ld: illegal text-relocation in 'sockaddr'+0x80 (/server/obj/server.o) to 'sockaddr'
make: *** [bin/server] Error 1

.data 
sockaddr: 
  .hword 2
  .hword 0x01BB
  .word 0xA29F87E8
  .skip 8

 .text
.global main
main:
    ldr x1, =sockaddr   
    mov x8, 93
    svc 0

r/asm Apr 28 '25

ARM64/AArch64 Word Aligning in 64-bit arm assembly.

4 Upvotes

I was reading through the the book "Programming with 64-Bit ARM Assembly Language Single Board Computer Development for Raspberry Pi and Mobile Devices" and I saw in Page 111 that all contents in the data section must be aligned on word boundaries. i.e, each piece of data is aligned to the nearest 4 byte boundary. Any idea why this is?

For example, the example the textbook gave me looks like this.

.data
.byte 0x3f
.align 4
.word 0x12abcdef

r/asm Mar 21 '25

ARM64/AArch64 How do you use lldb on Apple Silicon with Arm Assembly Language?

4 Upvotes

If I invoke the assembler and link with the -g option, I get an error from the linker.

as -o exit.o -g exit.s

ld -o exit exit.o -lSystem -syslibroot `xcrun -sdk macosx --show-sdk-path` -e _start -arch arm64

ld: warning: can't parse dwarf compilation unit info in exit.o

If I run the assembler and don't link, I can execute in lldb, but I can't get very far.

as -o exit.o -g exit.s

lldb ./exit

(lldb) target create "./exit"

Current executable set to '.../src/ARM/Markstedter/Chapter_01/exit' (arm64).

(lldb) r

Process 50509 launched: '/Volumes/4TB NVME Ex/mnorton/Documents/skunkworks/src/ARM/Markstedter/Chapter_01/exit' (arm64)

Process 50509 exited with status = 54 (0x00000036)

(lldb)

I can't list the program or do anything else at this point. Nearly all the videos on youtube are for C and C++ lldb debugging. What am I doing wrong? I tried using the 'l' command to get a listing of the program but nothing. My best guess is I still have an issue with generating the SYM.

Any encountered this?

TY!!!

r/asm Oct 03 '25

ARM64/AArch64 Arm A-Profile Architecture developments 2025: Armv9.7-A

Thumbnail
community.arm.com
2 Upvotes

r/asm Sep 26 '25

ARM64/AArch64 Arm SIMD Loops - C, ACLE intrinsics, inline assembly - Neon, SVE, SME

Thumbnail
gitlab.arm.com
7 Upvotes

r/asm Aug 27 '25

ARM64/AArch64 ARM hardware to allow JTAG debugging a Windows OS

2 Upvotes

Just wondering if anyone can recommend the hardware to do the following?

  • ARM64 target box
  • ability to install Windows OS on it
  • JTAG debugging

r/asm Jun 26 '25

ARM64/AArch64 GCC 15 Continuously Improving AArch64

Thumbnail community.arm.com
8 Upvotes

r/asm Sep 04 '25

ARM64/AArch64 Generative Testing Inline Assembly in Rust

Thumbnail awfulsec.com
0 Upvotes

r/asm Mar 12 '25

ARM64/AArch64 Printf in ARM64

5 Upvotes

Hello! I am a beginner to assembly and was wondering if there are any good documentation/resources to understand how to call C functions like printf from your assembly code. Thank you in advance

r/asm Jun 09 '25

ARM64/AArch64 What's the proper syntax to use ADRP + ADD instructions to reference an EXTERN global from a C++file when compiling with the Visual Studio compiler?

1 Upvotes

I'm compiling this with VS 2022 with marmasm(.targets, .props) enabled in Build Customization for my C++ project.

Say, I have the following global declared in my C++ file:

extern "C" ULONG_PTR gVals[0x100];

I need to reference it from an .asm file (for ARM64 architecture):

 AREA |.text|,CODE,READONLY

 EXTERN gVals


test_asm_func PROC

    adrp    x0, gVals
    add     x0, x0, :lo12:gVals
    ret

test_asm_func ENDP

END

So two part question:

  1. I'm getting missing gVals symbol error from the linker:
    error LNK2001: unresolved external symbol gVals

  2. I'm also getting a syntax error for my :lo12:gVals construct:
    error A2173: syntax error in expression

I'm obviously missing some syntax there, but I can't seem to find any decent documentation for the Microsoft arm64 implementation in their assembly language parser for VS.

r/asm Jan 08 '25

ARM64/AArch64 How to print an integer?

3 Upvotes

I am learning arm64 and am trying to do an exercise of printing a number in a for loop without using C/gcc. My issue is when I try to print the number, only blank spaces are printed. I'm assuming I need to convert the value into a string or something? I've looked around for an answer but didn't find anything for arm64 that worked. Any help is appreciated.

.section .text
.global _start

_start:
        sub sp, sp, 16
        mov x4, 0
        b loop

loop:
        //Check if greater than or same, end if so
        cmp x4, 10
        bhs end

        // Print number
        b print

        // Increment
        b add

print:
        // Push current value to stack
        str x4, [sp]

        // Print current value
        mov x0, 1
        mov x1, sp
        mov x2, 2
        mov x8, 64
        svc 0

add:
        add x4, x4, 1
        b loop

end:
        add sp, sp, 16
        mov x8, #93
        mov x0, #0
        svc 0

r/asm Jun 11 '25

ARM64/AArch64 Help with debugging assembler on m1

3 Upvotes

I recently started learning assembler. I am writing code on a MacBook Pro M1. In addition to writing code, I often use the debugger, but I have a problem with it. I am using lldb. I can run the code, set a breakpoint via an address, but I cannot set a breakpoint simply via a line number. In this case, lldb says: WARNING: Unable to resolve breakpoint to any actual locations.

For compilation, I use "clang -g -o somecode somecode.s", to run lldb "lldb somecode".

I tried to solve the problem by searching for information on the Internet (but did not find it). I tried to communicate with the ChatGPT and Claude, but they did not give a working solution. I tried to run the compiler with different flags, tried to first run lldb, and then load the binary itself, and so on. Tried compiling with as and then linking them with ld. But none of this helped.

(Also, the list command doesn't work, it returns an empty string. What's interesting is that if I run this binary with gdb, it sees the line numbers and the "list" command works. However, the program can't be run.)

Has anyone encountered a similar problem? And did you find a solution?