Program / Task Name:





Point Value:




Task Description

A simple computer has been designed to have the following general registers that are each 16-bits wide:  AX, BX, CX, and DX.

This same computer has the following simple operations that it can perform on any of the registers:

  • MOV reg1, reg2             - moves value of reg2 into reg1.
  • MOV reg1, <value>        - moves numeric value specified into reg1.
  • ADD reg1, reg2             - adds value of reg2 to reg1 and stores the sum in reg1.
  • ADD reg1, <value>        - adds the numeric value specified to reg1 and stores this sum in reg1.
  • SUB reg2, reg1              - subtracts the value in reg2 from the reg1 and stores this in reg1.
  • SUB reg1, <value>        - subtracts the numeric value specified from reg1 and stores this in reg1.
  • SHOW reg1                   - displays value in reg1 (in decimal) followed by a CR/LF.
  • HLT                              - signifies the end of the program. 

Note:  regx can be any of the registers (AX, BX, CX, or DX) and <value> is any whole decimal number 0 – 65535.  Assume that only a comma separates the destination and source fields.

Your task is to write a code interpreter that will execute a given program to completion.

Program Input

Your program will be given an input file ( with one operation per line.  It should execute all instructions until it reaches a “HLT”, and then exit.  A sample input file is shown below: 

MOV BX,2000

Program Output

Write the output to prob14.out as follows:




  (c) 2004 Hewlett-Packard Company