I made a small ARM assembler in Dart!
It just takes a string, like mov r0, #69
and emits the equivalent machine code: e3a00045
. Initial tests with dissasemblers show it works pretty well though this isn't a full assembler, you can't do linking, macros, labels or even psudo-ops like push. It also has very little safeguards for incorrect flags on some instructions for example a pre-indexed ldrt
.
Example output:
e3a00045 mov r0, #69
e12fff1e bx lr
09bc3ffc ldmedeq ip!, {a3-sp}
87e5d1ce strbhi r13, [v2, lr, asr #3]!
96992a4d ldrls a3, [sb], sp, asr #0x14
Live demo: https://dartpad.dartlang.org/9a4bb914d3d0d640061564517cf2e1ac
The following instructions are fully supported:
Data processing:
AND{S}, EOR{S}, SUB{S}, RSB{S}
ADD{S}, ADC{S}, SBC{S}, SRC{S}
TST{S}, TEQ{S}, CMP{S}, CMN{S}
ORR{S}, MOV{S}, BIC{S}, MVN{S}
Multiply:
MUL{S}, MLA{S}
UMULL{S}, UMLAL{S}, SMULL{S}, SMLAL{S}
Branching:
BX, BL, B
Load/Store:
STR{B}{T}, LDR{B}{T}
LDM{FD|ED|FA|EA|IA|IB|DA|DB}
STM{FD|ED|FA|EA|IA|IB|DA|DB}
SWP{B}
Syscall:
SWI, SVC
Condition codes:
EQ, NE, CS, CC
MI, PL, VS, VC,
HI, LS, GE, LT
GT, LE, AL