Documentation · version

Using phxdec

The same reference as README.txt in the zip. The commands are the same on Windows, macOS and Linux.

The page

phxdec
phxdec -gui

Run phxdec with nothing after it, or double-click it, and it opens the Phoenix Decompiler page in your default browser. Everything the command line does for one program is there: drop a program on it, tick Verify, Restore hand patches, Run unknown depackers or Quick, and press Decompile. The page shows phxdec's output as it comes, lists the files it wrote (view the listings, download any file, save them all as one zip or into a folder you name), and the Names and Comments tabs edit the names and comments files to decompile again with them.

The Phoenix Decompiler page with a GFA BASIC 3.50 program decompiled and verified, its files listed and its listing shown

The page is served by phxdec on your own computer only, at the address phxdec prints. Leave phxdec's window open while you use it, and press Quit on the page (or Ctrl+C in the window) to stop it. Each run is phxdec itself run again with the options you ticked, so the page gives exactly the results of the command line. Light and Dark switch its theme.

Scan

The page's Scan mode runs -scan, -scancompilers or -scanextensions on a folder, archive or disk image of your computer, with the options ticked. Each line shows as it comes, success, partial and failed in colour, with a running count; Stop ends the scan, and its log can be downloaded.

Clean up with AI

Under the listing, Clean up with Claude, Claude Code, ChatGPT, Gemini, Copilot, DeepSeek, Mistral or Grok sends the decompiled listing, its names and comments files and every rule they follow to that AI on your own account, in one request. The AI answers with real names and comments; phxdec checks the answer, writes NAME.NAM and NAME.CMT, and decompiles again with them and -verify. If that run stops on the files (a comment's line not found, say), it asks once more with the error.

ButtonWhat it needs
ClaudeAn Anthropic API key, or ANTHROPIC_API_KEY
Claude CodeNo key: your Claude plan (Pro or Max), through Claude Code on this computer, signed in once with claude and /login
ChatGPTAn OpenAI API key, or OPENAI_API_KEY
GeminiA Google AI Studio key, or GEMINI_API_KEY
CopilotA GitHub token with the Models permission, or GITHUB_TOKEN (through GitHub Models)
DeepSeekA DeepSeek API key, or DEEPSEEK_API_KEY
MistralA Mistral API key, or MISTRAL_API_KEY
GrokAn xAI API key, or XAI_API_KEY

Give the key under "AI keys and models"; each service's model list then shows the models it offers your key. A key goes only to that AI service, and stays in the browser only when you tick Remember.

Decompiling

phxdec program.prg [out_name] [-verify] [-lib LIBRARY] [-names NAMES_FILE] [-comments FILE] [-nosearch] [-run] [-restore]

The files go beside the program, or to out_name (its extension is dropped):

ProgramFiles written
GFA BASIC 3.xNAME.LST, the listing as the editor's Save,A writes it; NAME.GFA, the tokenised file the editor loads and the compiler compiles; XMODULE.O for the linker when the program has $X procedures
GFA BASIC 1.x/2.xNAME.LST and NAME.BAS, and phxdec prints the compiler options to use
Patched 1.x/2.xNAME.PAT, the bytes no source gives; NAME_XXXX.BIN for each block of DATA the code takes, with a Devpac NAME_XXXX.S for each block of machine code
STOS BASICNAME.BAS, the tokenised source STOS loads, and NAME.ASC, the listing as text (see STOS BASIC)
Omikron BASICNAME.BAS, the tokenised source the interpreter loads, and NAME.LST, the listing as text (see Omikron BASIC)
Every programNAME.NAM and NAME.CMT, the starter names and comments files (see Names and comments)
Packed programsNAME.UNP, the program depacked

phxdec says which compiler the program was made with, and prints the exact -compile command that rebuilds it with the same compiler and options. Lines it can't follow are kept as ' ?? comments, so the listing always loads.

OptionWhat it does
-verifyCompile the source again with the program's own compiler, write it as NAME.RE and compare it with the original byte for byte
-lib LIBRARY3.x: match the program with this library (a GFA3BLIB or a fingerprint file), for a program linked with a patched library
-names FILEGive variables, procedures and labels real names, one generated_name new_name pair a line (GFA, STOS and Omikron BASIC)
-comments FILEAdd comments to the listing, anchored to the units and lines they go with
-nosearchSkip trying the forms the compiler decides. Quicker, but the source may compile a little differently
-runDepack a program packed with an unknown packer by running its own depacker in the built-in 68000 interpreter
-restorePut back the original instructions of the hand patches phxdec recognises, then decompile the restored program (saved as NAME.RES)

A 3.x program linked with a library patched in a way phxdec knows is recognised, and -verify links with the library patched the same way. One example is the Falcon fix that patches out the Line-A mouse calls of HIDEM and SHOWM.

Verifying

-verify prints one verdict and sets the exit status:

verified: recompiles byte-identical
differs: first difference at $xxxx (sizes original/recompiled)

For 3.x, phxdec also prints how many units (procedures, functions and the main program) match, and which differ.

Some programs can't compile to the same bytes from any source, because the file isn't just what the compiler wrote. It may have been patched or cracked after compiling, padded or cut when it was copied, or damaged, or it may hold bytes left over from an earlier compile. The decompiled source of such a program is still right; only the file differs. phxdec counts these as the same:

  • pad bytes the compiler left to chance
  • a desk-accessory start-up added after compiling
  • the file ending, and a symbol table the original holds
  • a hand patch that phxdec can name and put back

Hand patches

Where the bytes show that a program was patched after compiling, the verdict names the patches, such as "hand-patched: nop in place of bne.s at $3074". -restore puts the original instructions back, saves the restored program as NAME.RES, decompiles that and, with -verify, compares against it:

restored: addq.l #4,a3 at $3074 (was nop)

The patches go in NAME.PAT as the program has them, so the patched program can be rebuilt exactly:

phxdec -compile NAME.LST -patch NAME.PAT

-verify checks this by writing NAME.PAT over the recompiled program, as -compile -patch does. When that doesn't give the program as found, a program that otherwise recompiles byte-identical is only partly verified:

NAME.PAT: checked: -compile -patch NAME.PAT gives the program as found

Damaged programs

A copy that lost code to a sector of zeros, or holds foreign bytes from a sector boundary, is reported as damaged, with the offset. The decompiled source is still right as far as the damage allows.

The original file is never changed. Patches phxdec can't name stay as they are and are still reported.

Compiling

phxdec -compile NAME.GFA|NAME.BAS|NAME.LST [out.prg] [-compiler NAME] [-opts OPTIONS] [-lib LIBRARY] [-acc] [-keep ROUTINES] [-patch NAME.PAT] [-pack PACKER]

The built-in GFA, STOS and Omikron compilers as a command-line compiler (see Omikron BASIC for its options). The program goes to out.prg, or to NAME.PRG by default. A .BAS is compiled with the 1.x/2.x compiler, or with the STOS compiler when it is a STOS source. A .LST is tokenised first, so keep the .GFA or .BAS that phxdec wrote beside it and the variables stay where they were.

OptionWhat it does
-compiler NAMEThe compiler to use, as phxdec -compiler list names them ("3.6 TT D", "3.02 E", "2.02 GB issued 1987-09-16", "2.06" ...). The default is the version a .GFA names, 2.02 GB for a 1.x/2.x .BAS and 2.06 for a STOS source
-opts OPTIONS1.x/2.x compiler options: stop=ever|loop|never, errors=text|no, bombs=+|-, trapv=+|-; or a STOS compile's settings as decompiling prints them
-lib LIBRARY3.x: link with this library instead of the version's own
-acc1.x/2.x: make the program into a desk accessory
-keep ROUTINES1.x: have the compiler take these runtime routines (hex numbers, comma separated)
-patch NAME.PAT1.x/2.x and STOS: write the patch file decompiling or -verify wrote over the compiled program
-pack PACKERPack the compiled program with one of the built-in packers

-compiler list marks some 1.x/2.x compilers as synthetic. They aren't releases GFA Systemtechnik made. Each one is a real compiler with another release's changes put in, standing in for a release no copy has been found of, so that programs made with it can be verified.

phxdec PROGRAM [out_name] [-verify] [-run]
phxdec SOURCE.BAS

A program compiled with the STOS BASIC compiler, run from GEM or from STOS, packed or not, is decompiled to NAME.BAS, the tokenised source STOS loads, and NAME.ASC, the listing as text. A tokenised STOS source (.BAS) given to phxdec is listed to NAME.ASC: it is already a source, so there is nothing to decompile. The compiler doesn't keep variable names or REM lines, so the names are made up.

-verify compiles the source again with the real STOS compiler built in, with its libraries and the extensions the program was made with, and compares it with the program as for GFA BASIC. Decompiling prints the command that compiles the source to the program again, and writes the files it needs beside the source:

phxdec -compile NAME.BAS -compiler 2.06 -opts gem,comptest=1,...

-opts holds the settings the program was compiled with. Files the program copied in (fonts, window and sprite libraries, the mouse) that aren't the compiler's own are written as NAME_FILE.

Compiler builds

Each build is named by the version it gives itself:

BuildWhat it is
1.1Mandarin (Jawx), with STOS BASIC 2.04
2.05Mandarin (Jawx), with STOS BASIC 2.05
2.06Mandarin (Jawx), with STOS BASIC 2.06
2.07The 2.07 update of the compiler only, with the STOSSER #17 bug fixers (1992)
2.07 (Anthony Jacques)Community: his STOS v2.07 Loader Program
3.0Community: 2.08 patched for all TOS versions by P. Putnik and exxos, March 2014

Extensions

A STOS program calls the compiler part of each extension it was made with (NAME.ECx, x the slot it loads into, A to Z), and a source names the extension's commands from its interpreter part (NAME.EXx). These are built in (C: compiler part, I: interpreter part):

SlotExtensionParts
ACOMPACTC, I
BTML Help (The Thug)I
CCOMPILERC, I
DMaestro (several builds)C, I
DSTE soundC
D, FGEMMA 1.52I
ESquasherC
FSTE Extension 3.0, 3.1, 3.5, 4.0 (Asa Burrows)C, I
FSixSticks 2.3 (A & L)I
FSticksI
GBlitter 1.0, 1.1 (A & L); Storm/GBP Blitter 1.0C, I
GFast 1.0 (Baz Molloy)C, I
HStars 2.6 (Lee Upcraft)C, I
ICodetextC, I
MMusician 0.06 (MIDI)C, I
MMisty (Top Notch)C, I
NGraphic-Extract 1.0C, I
NRNCC
NBitmaniaI
PPropack 1.00 (A. Cato)C, I
PGBP 4.7I
PDreams (Brian T. Innes)I
Q, R, SMissing Link (Top Notch), several buildsC, I
SSTOS 3DC, I
SSTOS Tracker 7, 10 and 14 kHzC
SICBIS 1 (Richard Hunt)I
TNinja Tracker 1.05C, I
TTOME (1989), TOME 2.1 (Shadow Software)C, I
USpectrum 512 1.8I
U, VEagle 0.8 (David Haylett)C, I
VSTOS Vidi 1.00C, I
WControl 3.00, 3.02, 3.05a, 3.05b, 3.06b (L.J. Greenhalgh)C, I
WBorder (Orbital Software)C, I
WEG example extension (M. Cubitt)C
XFalcon Extension 1.4 (Anthony Jacques)C, I
YCyber 1.00 (A. Cato, M. Cubitt)C, I
YFalcon audioC
ZExtra 1.01, 1.70, 2.10, 3.21, 3.26 (Martin Cubitt)C, I
ZMagnetic 3.6 (Ben Riley)I
ZModem, UsefullC, I

When a program calls a version of an extension that isn't built in, its calls are taken as the nearest routines of a version that is, and phxdec says so ("made with a version of extension Z phxdec does not have"). Please report such programs on the support forum, so the extension can be added. -scanextensions (see Scanning) finds the extensions in a collection that phxdec doesn't have.

STOS fixers

A STOS fixer (STOS Fixer, STOS_FIX and the like) changes a program's start-up code after compiling. When it rewrites the table of TOS addresses or the TOS check, -verify takes that for a hand patch: it goes in NAME.PAT and -restore puts it back. When it gives the program another compiler's longer start-up code, decompiling saves that as NAME_STARTUP.BIN, with a NAME.PAT that splices it into the compile, and the printed command has -patch NAME.PAT.

Omikron BASIC

phxdec PROGRAM [out_name] [-verify]
phxdec SOURCE.BAS
phxdec -compile SOURCE.BAS|SOURCE.LST [OUT.PRG] [-compiler NAME] [-opts link[=OON][,all]]

A program compiled with the Omikron BASIC compiler (2.x, 3.x or 4.x), one that loads its library (BASLIB, BASLIB_3, BASLIB_4) or one linked with it by CUTLIB, packed or not, is decompiled to NAME.BAS, the tokenised source the interpreter loads, and NAME.LST, the listing as text with each variable's type suffix. A tokenised Omikron BASIC source given to phxdec is listed to NAME.LST. The compiler keeps no variable names or REM lines, so the names are made up (L1%L, S2$, D3#); it keeps the line numbers when the program was compiled with them.

The Omikron BASIC decompiler is new in 1.2 and doesn't know all of the library's routines yet: code it doesn't know is kept in its line as a REM ?? with the instructions, and the result is partial. Please report such programs on the support forum.

-verify compiles a fully decompiled program again with the real Omikron BASIC compiler, with the build of the library the program was made with (linking it with CUTLIB when the original was linked), and compares the two byte for byte. The word holding the serial number of the compiler's copy is left out of the comparison, and phxdec says when it differs.

Compiler builds

BuildWhat it is
2.3ECompiler V2.3E, with BASLIB 2.0 and CUTLIB (the 2.2 disk)
2.4ECompiler V2.4E, with BASLIB 2.4 and CUTLIB
3.00Compiler V3.00, with BASLIB 3.00 (programs that load BASLIB_3)
3.05Compiler V3.05 (French), with BASLIB 3.05 and CUTLIB2
3.06Compiler V3.06, with BASLIB 3.05 and CUTLIB
3.59ECompiler 3.59E, with CUTLIB, BASLIB and FPULIB 3.57
4.08E_3.56, 4.08E_3.57Compiler 4.08E, with BASLIB_4 4.06, CUTLIB, and BASLIB and FPULIB 3.56 or 3.57

Decompiling prints the command that compiles the source to the program again:

phxdec -compile NAME.BAS -compiler 4.08E_3.57 -opts link

-compile takes a listing (.LST) too, as decompiling or the editor's SAVE ,A writes it. -opts link has CUTLIB link the library into the program; for the 2.x and 3.x CUTLIB, link=OON gives its three answers and all adds its -999.

Scanning

phxdec -scan PATH [-recurse] [-verbose] [-run] [-test [-cache] [-restore]] [-gfa] [-stos] [-omikron] [-log FILE] [-disable FORMATS]

Lists the GFA BASIC, STOS BASIC and Omikron BASIC programs in a file or folder, looking inside ZIP, LZH and ARJ archives, .ST, .MSA and .STX disk images, the disks of PMK v1.2 RAM disk programs and CD-ROM .ISO images, nested to any depth. Each program is printed with its path through the archives, its compiler and any packers. STOS sources (.BAS, .ACB) and memory banks (.MBK) aren't programs and aren't listed:

GAMES.ZIP/DISK1.ST/AUTO/FOO.PRG, GFA BASIC Compiler 3.6 TT D, packed (Ice 2.40)
OptionWhat it does
-recurseScan the folders below PATH too
-verboseList each archive, image or file that couldn't be read, with the reason
-runAlso find programs packed with an unknown packer, by running their own depacker (up to about a second a program)
-testDecompile and verify each program found, and print the result in colour
-cacheWith -test: test each program once; a copy of one tested before in the same scan takes its result
-restoreWith -test: put back the hand patches phxdec recognises before verifying each program, as -verify -restore does
-gfa, -stos, -omikronList only those BASICs' programs (none of them: all three)
-log FILEWrite every line to FILE as well, without colours, as the scan goes
-disable FORMATSLeave out the containers named, comma separated: iso, st, msa, stx, zip, lzh, arj, or diskimage and archive for each group, e.g. -disable iso,stx
GAMES.ZIP/DISK1.ST/AUTO/FOO.PRG, GFA BASIC Compiler 3.6 TT D: success - verified: recompiles byte-identical
tested 120: 95 success, 22 partial, 3 failed (41 copies of programs tested before, not tested again)

A scan writes no files. With -test, the files decompiling writes go to a temporary folder that is removed after each program.

Compilers and extensions

phxdec -scancompilers PATH [-recurse] [-verbose] [-gfa] [-stos] [-log FILE] [-disable FORMATS]
phxdec -scanextensions PATH [-recurse] [-verbose] [-log FILE] [-disable FORMATS]

-scancompilers lists the compilers instead, through the same folders, archives and disk images: GFA BASIC's compilers, linkers and libraries, and STOS BASIC's compilers and libraries. -scanextensions lists the STOS BASIC extensions, each part (.ECx or .EXx) with its slot and its version text. Each file is "known" when phxdec has the same bytes built in, else "NEW": those are the files worth sending in.

DISKS/STOS.MSA/COMPILER/COMPILER.PRG, STOS BASIC compiler, Stos basic compiler V 1.0 by Francois Lionet,
packed (Pompey Packer v1.5): known (build 1.1 COMP_204.PRG)
GBP/GBP.EXP, STOS BASIC extension, slot P, interpreter part, STORM/GBP Extension V4.7 (c)STORM '94 **: known

Unpacking and packing

Packed programs are depacked before decompiling, by phxdec's own routine for the packer or by the packer's own depack routine run in the 68000 interpreter. These packers are known:

PackerVersions
Atomik3.1, 3.3, 3.3B, 3.5
Automation2.3, 2.4, 2.51 (normal, buffer and chunked), 5.01 (normal, buffer and chunked)
CHFI/IMP Packer
Fire Packer1.01 (data files only), 2.01
JAM Packer2.4/3.0 (V2), 3.0 and 4.0 (LZH), 4.0 (LZW, Ice and V2)
Pack-Ice1.13, 2.11, 2.12, 2.20, 2.31, 2.34, 2.40
PFX/AFX-Packer2.1 (PFX 1.13P)
Pompey Pirates Packer1.5, 1.9, 1.9a
Powerpacker2.0, 3.0, 4.0
RNC Packer
Sentry2.05
Speed Packer2.0, 3.0
STCS Packer
UVK 2000's packer

A program packed with any other packer can be depacked with -run. To unpack a program only, GFA BASIC or not:

phxdec -unpack FILE
GAME.PRG: unpacked (Ice 2.40), 81234 bytes to 196608 bytes, saved as GAME.UNP
Result: success - unpacked (Ice 2.40)

To pack a program with one of the built-in packers (phxdec -pack list names them):

phxdec -pack FILE PACKER [OUT]

The built-in packers are the packer programs themselves, run in the 68000 interpreter, so the packed file is the one the packer writes:

  • Automation Packer 2.31, 2.41, 2.51 and 5.01
  • LSD Packer 1.2, 1.5 and 2.2, and JEK Packer 1.2d
  • Atomik Cruncher 3.3, 3.5 and 3.6
  • Pompey Pirates Packer 1.5 and 1.9a
  • JAM Packer 3.0 and 4.0 (each of their methods)
  • Pack-Ice 1.13, 2.11, 2.12, 2.20, 2.31, 2.34 and 2.40
  • PFX/AFX-Packer 2.1 (PFX 1.13P) by Thomas Quester and Markus Fritze

-verify of a program that holds one of their stubs packs the recompiled program the same way and compares it with the packed original too:

repacked with JAM Packer 4.0 (LZH): the same as the packed original

A program packed with a packer phxdec doesn't know can still be depacked with -run. phxdec then prints "depacked by running its own depacker (packer not recognised ...)". Please report these programs on the support forum, so the packer can get a routine of its own.

Names and comments

A decompiled listing has made-up names such as v02ce, proc_0023c, I4% or S3$, and no comments. Every decompile, of GFA BASIC 1.x, 2.x or 3.x, STOS BASIC or Omikron BASIC, also writes two starter files beside the listing:

  • NAME.NAM: every generated name the listing uses, each paired with itself (v02ce v02ce), under # headings;
  • NAME.CMT: the heading of every unit (@ main, @ PROCEDURE proc_0023c), with no comments yet.

Change the names on the right, add comments under the headings, and decompile again with them, so the listing still recompiles byte for byte:

phxdec GAME.PRG -names GAME.NAM -comments GAME.CMT -verify
# procedures
proc_0023c draw_board
# variables and arrays
v02ce      counter

In the comments file, the ' lines after a heading go before that unit; ^ text picks the next line of the unit starting with text, and the ' lines after it go before that line, a ! text line at its end.

@ PROCEDURE proc_0023c
' Draws the whole board
^ v02ce%=v02ce%+1
! one more move

The page's Clean up with AI buttons do all of this in one click with your own AI account. The prompts/ folder in the zip has prompts to do it by hand with an AI assistant, one prompt file at a time.

Results and exit status

Every run ends with one result line, printed last, in green, yellow or red on a colour console:

Result: success - every line decompiled
Result: partial - 2 of 6768 lines not decompiled (kept as ' ?? comments)
Result: success - recompiles byte-identical
Result: success - recompiles byte-identical apart from a hand patch: nop in place of trap #1 at $f2
Result: success - recompiles byte-identical after restoring 1 hand patch
Result: partial - decompiled, but recompiles differently: 20 of 25 units match
Result: success - wrote NAME.PRG
Result: failed
Exit statusMeaning
0Done. With -verify, the program recompiles byte-identical (apart from its file ending or a symbol table it holds)
1-verify: the program differs
2The program couldn't be decompiled, or the source didn't compile

Also: phxdec on its own opens the page, phxdec -h prints the usage text and phxdec -version prints the version number only.