Reference no: EM1333930
We have to write a c++ program for Little man's computer in which
Input:
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
Output:
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.
Example:
Input file contains following code (return positive difference):
901
310
901
311
210
808
510
211
902
000
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.