Home

Nima Alamatsaz

Welcome to BASM wiki!

What is BASM?

BASM is a user friendly and easy to use assembler for The Basic Computer, capable of creating the object, list and hex file and giving detailed error reports. It's more of academic use for students who wish to understand how does The Basic Computer actually work. Alongside this assembler, soon a simulator will also be available at BASM's SourceForge page.

How to use?

It is much more preferable to add BASM's 'bin' folder location to 'PATH' environment variable for both MS Windows and Linux users. You can also do it the easy way by copying the executable into a folder that is already added to 'PATH', like 'C:\Windows\' or '/bin/' (Windows users should also copy two .dll files). Then simply open a terminal and type:

$ basm test.asm



The output will be written to files 'test.obj', 'test.lst' and 'test.hex', respective to their source file name. You may want to change them:

$ basm test.asm -o objectfile.obj -l listfile.lst -h hexfile.hex



Follow these links and see how to add a location to the 'PATH':
http://windows7hacker.com/index.php/2010/05/how-to-addedit-environment-variables-in-windows-7/
http://linuxheadquarters.com/howto/basic/path.shtml

How to compile from source?

MS Windows users can open 'basm.sln' under 'prj\vs10' with Visual Studio 2010
or later (either the express or full version), and simply compile the solution.
The executable binary output will be saved as 'bin\basm.exe'.
Under linux, if you have g++ (GNU C++ Compiler), just run 'compile.sh' script:

$ ./compile.sh



In case something went wrong, change the script's permissions:

$ chmod 755 compile.sh



Then try running it again. The binary output will be saved as 'bin/basm'.

Instruction Set

Instruction Description
MRI
AND X and MEM[X] with AC and store the result in AC
ADD X add MEM[X] to AC and store the result in AC
LDA X copy MEM[X] into AC
STA X copy AC into MEM[X]
BUN X jump to X unconditionally ( PC ← X )
BSA X save current PC in MEM[X] and jump to X+1 unconditionally ( MEM[X] ← PC, PC ← X+1 )
ISZ X increase MEM[X] by one, and skip the next instruction if MEM[X] equals zero
Non MRI
CLA clear AC
CLE clear E flag
CMA complement AC
CME complement E flag
CIR circular shift AC to right
CIL circular shift AC to left
INC increase AC by one
SPA skip next line if AC is positive
SNA skip next line if AC is negative
SZA skip next line if AC equals zero
SZE skip next line if E flag equals zero
HLT halt execution of the program
I/O
INP read the input register (INPR) and store it in the lower 8 bit of AC
OUT write the lower 8 bit of AC to output register (OUTR)
SKI skip next line if input flag (I) is set
SKO skip next line if output flag (O) is set
ION set the interrupt flag (R)
IOF clear the interrupt flag (R)
Pseudo
ORG N sets the next line's address to N
END indicates the end of program
DEC N interpreting N as a decimal data, assembler stores it in the memory
HEX N interpreting N as a hexadecimal data, assembler stores it in the memory
BIN N interpreting N as a binary data, assembler stores it in the memory

Web and contact

Visit BASM's page at SourceForge:
http://sf.net/p/basm

Ask questions, report bugs and give suggestions here:
http://sf.net/p/basm/discussion
http://sf.net/p/basm/tickets