programs

package
v0.0.0-...-9fd96d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2021 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuiltinRegistry = map[string][]*asm.Instruction{
	"calculator": Calculator,
}

A registry of all the builtin programs. NOTE: All names should be in lower case, as all queries should be.

View Source
var Calculator = []*asm.Instruction{

	start.Apply(asm.INP()),
	asm.STA(mode),

	asm.INP(),
	asm.STA(value_o),
	asm.INP(),
	asm.STA(value_t),

	asm.LDA(mode),
	asm.BRZ(addition),
	asm.BRA(subtract),

	addition.Apply(asm.LDA(value_o)),
	asm.ADD(value_t),
	asm.BRA(end),

	subtract.Apply(asm.LDA(value_o)),
	asm.SUB(value_t),
	asm.BRA(end),

	end.Apply(asm.OUT()),
	asm.HLT(),

	asm.DAT(mode),
	asm.DAT(value_o),
	asm.DAT(value_t),
}

A dual-function calculator program. It will prompt for 3 inputs:

  1. The function to use (0 = addition, 1 = subtract)
  2. The first number to use
  3. The second number to use

The program will then output the result.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL