C Disassembly
Open a compiled Atari C program in a normal disassembler and the first thing you hit is a wall of mystery subroutines — BSR _L004820, BSR _L00491C — with raw values pushed onto the stack or loaded into registers before each call. Half the program is standard C library code and compiler math helpers, but without symbols you have to reverse-engineer strcpy, malloc, and 32-bit multiply by hand before you even reach the actual program.
rg-dis recognises which Atari C compiler built the binary, names the standard library and runtime routines automatically, and traces each call's arguments and return values right in the listing — turning anonymous BSRs back into readable calls like _Fopen(filename="CONFIG.INF", mode=read-only (0)).
Toolchains
rg-dis auto-detects the toolchain and ABI from the binary's startup sequence and library fingerprints, modelling 16-bit vs 32-bit int sizes, stack vs register parameter passing, and pointer return registers (D0 vs A0). You can also force any profile explicitly with --c-abi <PROFILE>:
| Toolchain | Calling Conventions | --c-abi Profiles |
|---|---|---|
| Pure C / Turbo C | Register fastcall (default), stack |
purec-register, purec-stack |
| VBCC | 16/32-bit cdecl stack, fastcall |
vbcc32-stack, vbcc16-stack |
| Lattice C 5.x | 16/32-bit cdecl, __regargs |
lattice32-stack, lattice16-stack, lattice32-register, lattice16-register |
| AHCC | Register fastcall, cdecl stack |
ahcc-register, ahcc-stack |
| Sozobon C | 16/32-bit cdecl stack |
sozobon16-stack, sozobon32-stack |
| Alcyon C (DRI) | 16-bit cdecl stack |
alcyon16-stack |
| Megamax / Laser C | 16-bit cdecl stack |
megamax16-stack |
| Mark Williams C | cdecl stack |
— |
| Mintlib / GCC | 16/32-bit cdecl stack |
gcc-mint32-stack, gcc-mint16-stack |
Standard Library
Subroutines matching known library patterns are promoted from anonymous labels to canonical symbol names with a header comment identifying the compiler family:
; compute length of string (VBCC standard)
_strlen:
MOVEA.L 4(A7),A1
MOVEQ #0,D0
MOVEA.L A1,A0
ADDQ.L #1,A1
TST.B (A0)
BEQ.S .L000010
ADDQ.L #1,D0
MOVEA.L A1,A0
ADDQ.L #1,A1
TST.B (A0)
BNE.S .L000008
.L000010:
RTS
Comparison
Without compiler and library awareness, a sequence of C calls looks like anonymous subroutines fed by raw stack pushes and register loads:
Without C annotations
MOVE.W #0,-(A7)
PEA _L008120(PC)
BSR.W _L004A10
ADDQ.L #6,A7
PEA _L008134(PC)
PEA -100(A6)
BSR.W _L004820
ADDQ.L #8,A7
MOVE.L D3,D0
MOVE.L #320,D1
BSR.W _L004C90
With rg-dis C annotations
MOVE.W #0,-(A7) ; Fopen mode: read-only (0)
PEA STR_CONFIG(PC) ; Fopen filename: "CONFIG.INF"
BSR.W _Fopen ; call _Fopen(filename="CONFIG.INF", mode=read-only (0))
ADDQ.L #6,A7
PEA STR_SRC(PC) ; strcpy src: "SCORE: 0000"
PEA -100(A6) ; strcpy dest: [a6-100]
BSR.W _strcpy ; call _strcpy(dest=[a6-100], src="SCORE: 0000")
ADDQ.L #8,A7
MOVE.L D3,D0 ; __divu dividend: D3
MOVE.L #320,D1 ; __divu divisor: 320
BSR.W ___divu ; call ___divu(dividend=D3, divisor=320)
Arguments
rg-dis walks backwards from BSR and JSR call sites through the preceding instructions to bind arguments and decode OS enumeration constants.
Stack Passing (cdecl — VBCC, Lattice, Mintlib, Sozobon)
PEA STR_SRC(PC) ; strcpy src: "SCORE: 0000"
PEA -100(A6) ; strcpy dest: [a6-100]
BSR.W _strcpy ; call _strcpy(dest=[a6-100], src="SCORE: 0000")
ADDQ.L #8,A7
Register Passing (fastcall — Pure C, AHCC, Lattice __regargs)
LEA STR_DEST(PC),A0 ; strcpy dest: STR_DEST [fastcall A0]
LEA STR_SRC(PC),A1 ; strcpy src: STR_SRC [fastcall A1]
BSR.W _strcpy ; call _strcpy(dest=STR_DEST, src=STR_SRC)
OS Wrapper Stubs & Constant Decoding
Calls to standard C wrappers around GEMDOS, BIOS, XBIOS, AES, and VDI (_Fopen, _Fseek, _Setscreen, _form_do, _v_gtext) decode numeric mode flags into readable names:
MOVE.W #0,-(A7) ; Fopen mode: read-only (0)
PEA STR_CONFIG(PC) ; Fopen filename: "CONFIG.INF"
BSR.W _Fopen ; call _Fopen(filename="CONFIG.INF", mode=read-only (0))
ADDQ.L #6,A7
Runtime Math Helpers
MOVE.L D3,D0 ; __divu dividend: D3
MOVE.L #320,D1 ; __divu divisor: 320
BSR.W ___divu ; call ___divu(dividend=D3, divisor=320)
Custom Contracts
When reverse-engineering a binary whose symbols were stripped or where you have your own header definitions, you can supply custom function signatures and struct/type layout definitions (--c-contracts) so rg-dis annotates your own routines and call-site parameters using the same call-site tracer.