Explore BrainMass

Explore BrainMass

    C++ Little Man's computer program

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    We have to write a c++ program for Little man's computer in which

    A text file containing machine code (not assembly code) for little man's computer following instruction set . Instructions are in different lines (no need for semicolon at the end of each instruction)

    Arithmetic 1xx ADD
    2xx SUB
    Data Movement 3xx STORE
    5xx LOAD
    BR 6xx JUMP
    BRZ 7xx BRANC ON 0
    BRP 8xx BRANCH ON +
    Input/Output 901 INPUT
    902 OUTPUT
    Machine Control 000 HALT
    (coffee break) COB

    Any output specified in the input file by 902 will be displayed on screen

    Computer specification:
    · Two digits memory (mail box) address: 00-99

    · Three digits instruction or data in each memory slot

    · One calculator, one program counter

    · The program in the input file needs to be loaded into memory first and stored in consecutive slots starting from address 00

    · 901 instruction will ask user's input from keyboard, 902 displays content in calculator

    Other requirements:
    Your program should accept any length of input program that can be fit in little man's 100 memory slots and generate correct result and/or output on screen.

    Submit the source code together with readme file with instruction to compile, build and use your program.

    Input file contains following code (return positive difference):
    Running of the program with this input will ask user to input 2 numbers, let's say 5 and 10, the program will output the positive difference on the screen, which is 5.

    © BrainMass Inc. brainmass.com October 9, 2019, 11:07 pm ad1c9bdddf

    Solution Preview

    Attached is the C++ code for Little Man's computer and inputData.txt which contains the test program. The inputData file must be in the same location as the program. The code can be implemented in many ways, so this ...

    Solution Summary

    A C++ Program Simulating Little Man's Computer. Reads simple machine code from input file and interprets it to execute arithmetic commands.