MAWA - A language as simple as Python but as powerful as Assembler, modern ASM but much simpler
Source: Dev.to
MAWA – a programming language with Python‑like syntax and the low‑level power of an assembler
Although MAWA has been mentioned before, this post dives into its compilation model and shows a concrete example of a MAWA command.
Background
MAWA aims to be simpler than most languages, both in syntax and in the compilation pipeline.
Traditional C/C++ compilation (source → object → executable → binary) requires several tools.
MAWA, like NASM, compiles directly to a binary image:
- NASM –
.asm→.bin - MAWA –
.mawa→.bin(using a custom compiler)
Syntax vs. Assembly
In many assembly or C programs several lines are needed for simple output.
MAWA can express the same operation in a single statement.
MAWA example
Imp ('A', DefFinLinea(1), 'B', 0x0A)
FinalLoop (No Extensiones)
Impprints the character'A', callsDefFinLinea(1)to emit a line break, prints'B', and finally sets the colour attribute0x0A.0x0A→ background = 0 (black), foreground = A (light‑green).
FinalLoopcreates an infinite loop to prevent the CPU from reading stray bytes (useful when running under QEMU).
Equivalent NASM – 16‑bit version
BITS 16
startCode:
mov ax, 0x0003
int 0x10
mov ah, 0x09
mov al, 'A'
mov bl, 0x0A
mov bh, 0x00
mov cx, 1
int 0x10
call endLine
mov ah, 0x09
mov al, 'B'
mov bl, 0x0A
mov bh, 0x00
mov cx, 1
int 0x10
jmp $
endLine:
mov ah, 0x0E
mov al, 0x0D
int 0x10
mov ah, 0x0E
mov al, 0x0A
int 0x10
ret
times 510 - ($ - $$) db 0
dw 0xAA55
- The code prints
AandBusing BIOS interrupt 0x10 with colour attribute 0x09. endLineinserts the CR+LF bytes (0x0D 0x0A) via interrupt 0x10.- The final
jmp $creates an infinite loop, mirroringFinalLoopin MAWA.
Equivalent NASM – 32‑bit version
BITS 32
mov edi, 0xB8000 ; VGA text‑mode base address
mov byte [edi], 'A' ; character
mov byte [edi+1], 0x0A ; colour (light‑green on black)
add edi, 160 ; move to next line (80 columns × 2 bytes)
mov byte [edi], 'B'
mov byte [edi+1], 0x0A
jmp $ ; infinite loop
- Directly writes characters and colour attributes into video memory.
add edi, 160advances the cursor to the next line.
Comparison
| Aspect | MAWA | NASM 16‑bit | NASM 32‑bit |
|---|---|---|---|
| Source file | .mawa | .asm | .asm |
| Compilation step | Direct → .bin | Direct → .bin | Direct → .bin |
| Lines of code (example) | 2 statements | ~20 lines | ~9 lines |
| Colour handling | Single argument (0x0A) | Separate registers (bl, bh) | Direct byte write |
| Loop termination | FinalLoop (infinite) | jmp $ | jmp $ |
Further work
A larger project, Win Anti App Anchor, is being built with MAWA as its core language. More details will be shared in upcoming posts.
References
- Original MAWA announcement (Spanish):