summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/tq.rs62
1 files changed, 35 insertions, 27 deletions
diff --git a/src/bin/tq.rs b/src/bin/tq.rs
index b27f702..885c46c 100644
--- a/src/bin/tq.rs
+++ b/src/bin/tq.rs
@@ -42,56 +42,64 @@ fn main() {
if verbose { log::set_log_level(log::LogLevel::Info) }
if print_version {
let version = env!("CARGO_PKG_VERSION");
- eprintln!("torque assembler, version {version}");
- eprintln!("written by ben bridle");
+ eprintln!("Torque meta-assembler, version {version}");
+ eprintln!("by Ben Bridle (https://derelict.engineering)");
std::process::exit(0);
}
if print_help {
eprintln!("\
Usage: tq [source] [destination]
-Torque multi-assembler, see http://benbridle.com/torque for documentation.
+Torque is a lightweight meta-assembler (see http://benbridle.com/torque).
+
+Usage:
+ To assemble a Torque program from a source file and write to an output
+ file, run `tq [source] [destination]`, where [source] is the path
+ of the source file and [destination] is the path to write to.
+
+ If [destination] is omitted, the assembled program will be written to
+ standard output. If [source] is omitted, the program source code will
+ be read from standard input.
+
+Environment variables:
+ TORQUE_LIBS
+ A list of colon-separated paths that will be searched to find Torque
+ source code files to use as libraries when assembling a Torque program.
+ If a library file resolves an unresolved symbol in the program being
+ assembled, the library file will be merged into the program.
Arguments:
- [source] Path to a source file to assemble
- [destination] Path to which output will be written
+ [source] Torque source code file to assemble
+ [destination] Destination path for assembler output
Switches:
- --extension=<ext> File extension to identify library files (default is 'tq')
- --format=<fmt> Format to apply to assembled bytecode (default is 'debug')
+ --dry-run (-n) Assemble and show errors only, don't write any output
+ --extension=<ext> File extension to identify source files (default is 'tq')
+ --format=<fmt> Output format to use for assembled program (default is 'debug')
--width=<width> Force a fixed width for all assembled words
--no-project-libs Don't search for libraries in the source parent folder
--no-env-libs Don't search for libraries in the TORQUE_LIBS path variable
--no-libs Combination of --no-project-libs and --no-env-libs
- --tree Display a tree visualisation of all included library files
- --dry-run (-n) Assemble and show errors only, don't write any output
+ --tree Show a tree diagram of all included library files
--help (-h) Print this help information
--verbose, (-v) Print additional information
- --version Print the assembler version and exit
-
-Environment variables:
- TORQUE_LIBS
- A list of colon-separated paths which will be searched to find
- Torque source code files to use as libraries when assembling a
- Torque program. If a library file resolves an unresolved symbol
- in the program being assembled, the library file will be merged
- into the program.
+ --version Print the program version and exit
Output formats:
- <debug>
+ cmd
+ CMD module load format used by the CP/M operating system.
+ debug
Print assembled words as human-readable binary literals.
- <inhx>
+ inhx
Original 8-bit Intel hex format.
- <inhx32>
+ inhx32
Modified 16-bit Intel hex format used by Microchip.
- <raw>
+ raw
Assembled words are converted to big-endian bytestrings and concatenated.
Each word is padded to the nearest byte. Words must all be the same width.
- <source>
+ source
Print the source file before assembly, with symbols resolved.
-
-Created by Ben Bridle.
- ");
+");
std::process::exit(0);
}
@@ -169,9 +177,9 @@ Created by Ben Bridle.
}
};
-
if !dry_run {
let result = match format {
+ Format::Cmd => format_cmd(&segments),
Format::Debug => format_debug(&segments),
Format::Inhx => format_inhx(&segments),
Format::Inhx32 => format_inhx32(&segments),