PDPy11 Compiler
(c) 2018 Ivanq

Usage:
pdpy11 file.mac                 Compile file.mac to file.bin                    
pdpy11 file.mac --bin           Compile file.mac to file.bin, replaces          
                                make_raw / make_bk0010_rom / make_bin /         
                                make_sav / make_turbo_wav / make_wav            
pdpy11 file.mac --sav           Compile file.mac to file.sav, replaces          
                                make_raw / make_bk0010_rom / make_bin /         
                                make_sav / make_turbo_wav / make_wav            
pdpy11 file.mac --turbo-wav     Compile file.mac to file.wav, replaces          
                                make_raw / make_bk0010_rom / make_bin /         
                                make_sav / make_turbo_wav / make_wav            
pdpy11 file.mac --wav           Compile file.mac to file.wav, replaces          
                                make_raw / make_bk0010_rom / make_bin /         
                                make_sav / make_turbo_wav / make_wav            
pdpy11 file.mac --raw           Compile file.mac to file, without bin header    
pdpy11 a b c                    Compile & link files a, b and c to a.bin        
pdpy11 a b c -o proj --raw      Compile & link files a, b and c to proj (w/o bin
                                header)                                         
pdpy11 a b c -o proj            Compile & link files a, b and c to proj.bin (w/ 
                                bin header)                                     
pdpy11 --project dir            Compile & link file dir/main.mac (see Project   
                                mode)                                           

pdpy11 file.mac --lst           Generate listing file "file.lst"                

--link n                        Link file/project from 0oN (default -- 0o1000)  

--syntax pdp11asm               Use pdp11asm bugs/features: @M is same as @M(PC)
                                (M is not resolved to M-.), .INCLUDE is same as 
                                .INCLUDE .END                                   
--syntax pdpy11                 (default) Use PDPy11 features, fix pdp11asm     
                                bugs. This is the recommended mode for all new  
                                projects.                                       
-Dname=value                    Set global label <name> to integer <value>      
                                (parsed using assembler rules)                  
-Dname="value" or               Set global label <name> to string <value>       
-Dname='value' or                                                               
-Dname=/value/                                                                  

--sublime                       Output errors in Sublime-compatible format. This
                                allows Sublime to show errors inline.           

Directives:
ORG n / .LINK n / .LA n         Link file from N (replaces --link). However, if 
                                an included file contains .LINK, the included   
                                file will be linked from N, but written to ".". 
.INCLUDE "filename" /           Compile file "filename", then return to current 
.RAW_INCLUDE filename           file. Embed "filename" to current binary file,  
                                and link it from ".".                           
                                In "pdp11asm" mode, .INCLUDE is same as .INCLUDE
                                .END, and .RAW_INCLUDE is same as .INCLUDE.     
                                In "pdpy11" mode, they work the same way, only  
                                syntax differs.                                 
                                Technically, this is the same as directly       
                                inserting the included file's source code to    
                                current file, with only .EXTERNal labels being  
                                visible to other files. This also means that    
                                including a file that has ".EXTERN" twice is    
                                not a good idea -- an error will be raised, as  
                                labels are redefined. Use ".ONCE" to fix this.  
.PDP11                          Ignored                                         
.i8080                          Emits syntax error                              
.SYNTAX {pdp11asm/pdpy11}       Change syntax locally, for 1 file               
.DB n / .BYTE n / DB n          Emits byte N                                    
.DW n / .WORD n / DW n          Emits word N                                    
.END / END                      Same as EOF; inside .REPEAT block works like    
                                'continue' operator                             
.DS n / .BLKB n / DS n          Emits N zero bytes                              
.BLKW n                         Emits N zero words (N * 2 bytes)                
.EVEN                           If . points to an odd address, emit 1 zero byte 
ALIGN n                         Align . by n, ceiling if n is not a divisor of  
                                ".".                                            
.ASCII "..."                    Emits string                                    
.ASCII "..." <12> "..."         Emits a string, then a newline, then a string   
.ASCIZ "..."                    Emits string, plus zero byte                    
make_raw ["..."]                Same as --raw. If string is passed, this is the 
                                resulting filename.                             
make_bk0010_rom ["..."] /       Same as --bin. If string is passed, this is the 
make_bin ["..."]                resulting filename.                             
make_sav ["..."]                Same as --sav. If string is passed, this is the 
                                resulting filename.                             
make_turbo_wav ["..." ["..."]]  Same as --turbo-wav. If a string is passed, this
                                is the resulting filename. If two strings are   
                                passed, the first one is the real filename and  
                                the second one is BK filename.                  
make_wav ["..." ["..."]]        Same as --wav. If a string is passed, this is   
                                the resulting filename. If two strings are      
                                passed, the first one is the real filename and  
                                the second one is BK filename.                  
convert1251toKOI8R {ON|OFF}     Ignored                                         
decimalnumbers {ON|OFF}         If ON, N is the same as N., and you must use    
                                0oN or 0N or No for octal. This does not affect 
                                --link and other CLI arguments.                 
insert_file "filename"          Insert raw file "filename" to .                 
.REPEAT count { code }          Repeat code inside .REPEAT block <count> times  
.EXTERN NONE /                  Sets which labels are visible in other files.   
.EXTERN ALL /                   "NONE" means all global labels are visible in   
.EXTERN label1[, label2[, ...]] current file, but not others. "ALL" is the same 
                                as mentioning all the labels defined in current 
                                file. See also: Project mode.                   
.ONCE                           Makes current file includable only once -- if it
                                was included before, it works like ".END".      

Project mode
PDPy11 can compile projects. Use `--project directory` CLI argument for this.   
PDPy11 will compile all files (except the ones mentioned in `.pdpy11ignore` --  
see below) containing `make_raw`, `make_bk0010_rom`, `make_bin`, `make_sav`,    
`make_turbo_wav` or `make_wav` directive. Such files are called "include roots".

In project mode, `.INCLUDE` and `.RAW_INCLUDE` can include directories, which   
means to include all `.mac` files inside the directory (except files mentioned  
in `.pdpy11ignore`).                                                            

.pdpy11ignore
This file has syntax similar to `.gitignore`. It sets what files to ignore when 
including directories.                                                          
Example:                                                                        
filename.mac    ; Ignore all files called filename.mac                          
a/*             ; Ignore files in "a" directory and "whatever/a" directory      
/a              ; Ignore files in "a" directory only                            
test.mac/       ; Ignore everything inside "test.mac" directory and             
                ; whatever/test.mac" directory, but not "test.mac" file or      
                ; "whatever/test.mac" file                                      
