AVM: A Virtual Machine
Size 39kb, downloads 758.
While working at the University of Lincolnshire and Humberside I developed a little home project, AVM, partly for my own amusement and partly to help my colleague Angus Marshall, who was teaching operating systems. It simulates a very simple computer for teaching purposes. Some extracts from the manual below explain in more detail what it does.
AVM is an educational tool to simplify the concepts of machine code programming and assembly language. To do so, it provides a virtual processor much simpler than any in common use since the 1980s. Its small memory capacity encourages the implementation of small and simple projects, which will allow a student to concentrate on the concepts of programming, rather than in fine details of the implementation of ambitious projects
The CPU can best be described as a 4-bit machine. Though the memory is addressed as 8-bit bytes, most instructions have 4-bit opcodes, with the other half of the byte being occupied with a cascade code or part of an address operand.
The virtual machine provides two forms of input/output. The simplest is console I/O, which is tied to stdin/stdout when running the virtual machine, simulating the connection of a terminal. More complex is a virtual disk drive, stored as a file on the host system, which allows the state to be carried over from one session to the next.
There are three tools provided as part of the package: a simple hex loader, an assembler, and the virtual machine itself. The software tools make use of three types of files. These are hex files, assembly code files, and machine code image files.
An Example Program for AVM
This program is from the manual. It simply prints the text "Hello". It can be fed directly to the assembler program AVMA as formatted below.
;; ;; hello.asm ;; Simple Hello example program ;; ;; ;; Definitions and origin ;; IOCTL: EQU $FFE ; I/O Control address IODATA: EQU $FFF ; I/O Data address IOCPRT: EQU $02 ; IOC PriNT instruction ORG $000 ;; ;; Initialise ;; LDA #HELLO ; Point to the stored text ;; ;; Print each character ;; LOOP01: LDD ; Look at the current character JEQ FINISH ; End if it is a terminating NUL STD IODATA ; Store ready for output LDD #IOCPRT ; Load the IOCPRT instruction STD IOCTL ; Perform the IOCPRT INC ; Point to the next character JMP LOOP01 ; Do it all again ;; ;; Finish printing ;; FINISH: RET ; Return (or halt) ;; ;; The text stored ;; HELLO: DEF $48 ; H DEF $65 ; e DEF $6C ; l DEF $6C ; l DEF $6F ; o DEF $0A ; LF DEF $00 ; NUL
Where to get AVM
You're welcome to use AVM yourself for teaching or other purposes. It may be useful if machine code or assembly language are still taught nowadays. Click on the link above to download the source code. If you're at all interested in a tool like this then I'm sure you know what to do with the source code!