Skip to content

Commit

Permalink
cmd/retro: add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
db47h committed Aug 24, 2016
1 parent 0ba3ee0 commit 4844a0b
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 4 deletions.
85 changes: 85 additions & 0 deletions cmd/retro/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// This file is part of ngaro - https://github.com/db47h/ngaro
//
// Copyright 2016 Denis Bernard <db047h@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// The retro command line tool is a a showcase for the package github.com/db47h/ngaro/vm
// and can be used as a high performance replacement for the Retro reference implementations.
//
// See aslo http://forthworks.com/retro/ for more information on Retro.
//
// Usage:
//
// -debug
// enable debug diagnostics
// -dump
// dump stacks and memory image upon exit, for ngarotest.py
// -ibits value
// cell size in bits of loaded memory image (default GOARCH bits)
// -image filename
// Load memory image from file filename (default "retroImage")
// -noraw
// disable raw terminal IO
// -noshrink
// When saving, don't shrink memory image file
// -o filename
// filename to use when saving memory image
// -obits value
// cell size in bits of saved memory image (default GOARCH bits)
// -size int
// runtime memory image size in cells (default 100000)
// -with filename
// Add filename to the input list (can be specified multiple times)
//
// -debug: will print a full stacktrace should the VM crash.
//
// -dump: this boolean flag is meant to be used in conjonction with the Retro
// test suite. It will dunp the stacks and memory image to stdout.
//
// -noraw: upon startup, retro switches the terminal to raw mode unless stdin
// has been redirected. This flag disables this behavior.
//
// -image: memory image file to load on startup. The default is a file named
// "retroImage" in the current directory.
//
// -size: total memory image size (in cells) to use at runtime. It may be
// automatically extended to fit the loaded memory image file. Make sure that
// this value is sufficiently big to have some free cells as temporary storage.
//
// -with: After loading the memory image, retro will feed the specified file to
// the VM as input. If specified multiple times, files will be fed to the VM in
// order of appearance on the command line.
//
// -o: filename to use when saving the memory image. In Retro, the "save" wword
// saves the memory image to disk. This can also be done in Ngaro assembler with
// the following code:
//
// .org 32 ( or whatever address above 32 )
// :save
// 1 4 out
// 0 0 out
// wait ;
// save
//
// -noshrink: in the Retro language, the number of cells allocated inside the
// memory image is stored in cell #3. By default, this value is used to save
// only that many cells. Use this flag if you are running a memory image
// incompatible with this scheme, or if you want to make a full snapshot of the
// VM memory, including temp data.
//
// -ibits, -obits: control respectively the cell size in bits of the input and
// output memory images. These flags are primarily meant to convert memory
// images between different cell sizes. For more details on 32/64 bits handling
// and examples, please see https://github.com/db47h/ngaro/blob/master/README.md
package main
8 changes: 4 additions & 4 deletions cmd/retro/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ func main() {

var fileName = flag.String("image", "retroImage", "Load memory image from file `filename`")
flag.Var(&srcCellSz, "ibits", "cell size in bits of loaded memory image")
var size = flag.Int("size", 100000, "image size in cells")
flag.BoolVar(&dump, "dump", false, "dump stacks and image upon exit, for ngarotest.py")
var size = flag.Int("size", 100000, "runtime memory image size in cells")
flag.BoolVar(&dump, "dump", false, "dump stacks and memory image upon exit, for ngarotest.py")
flag.Var(&withFiles, "with", "Add `filename` to the input list (can be specified multiple times)")
flag.BoolVar(&noShrink, "noshrink", false, "When saving, don't shrink image")
flag.BoolVar(&noShrink, "noshrink", false, "When saving, don't shrink memory image file")
flag.BoolVar(&noRawIO, "noraw", false, "disable raw terminal IO")
flag.BoolVar(&debug, "debug", false, "enable debug diagnostics")
flag.StringVar(&outFileName, "o", "", "`filename` to use when saving memory image")
flag.Var(&dstCellSz, "obits", "cell size in bits of saved image")
flag.Var(&dstCellSz, "obits", "cell size in bits of saved memory image")

flag.Parse()

Expand Down

0 comments on commit 4844a0b

Please sign in to comment.