Hi.if possible can somebody tell me how to make a start to write this pseudocode in LC3 assembly lang.
thank you
Pseudocode for PC Interpreter
subroutine execute(program_pointer) {
while (true) {
switch (the value at the program pointer) {
case '.':
Output the value at the data pointer as an ASCII character
break;
case ',':
Read a character from the keyboard
Set the value at the data pointer to the character you just read
break;
case '>':
Increment the data pointer
break;
case '<':
Decrement the data pointer
break;
case '+':
Increment the value at the data pointer
break;
case '-':
Decrement the value at the data pointer
break;
case 'X':
halt the simulator
case ' ':
case '\n':
Ignore spaces and newline characters
break;
default: //error
This situation will never occur
}
Increment the program pointer by 1
}
}
Each instruction does a particular function, using this data. Here
are the instructions:
'>' This increments the data pointer.
if the data pointer was at x6002, it is now pointing at x6003
'<' This decrements the data pointer.
if the data pointer was at x6005, it is now pointing at x6004
'+' This increments the value at the pointer.
if the data pointer is at x6007, and the value at x6007 is
14, it is now 15
'-' This decrements the value at the pointer.
if the data pointer is at x6003, and the value at x6003 is
27, it is now 26.
'.' This outputs the value (as ASCII) at the pointer.
if the data pointer is at x6008, and the value at x6008 is
65, it will output A.
',' This inputs a character value into the value at the pointer.
if the data pointer is at x6013 and the user types 'A', then
65 will be loaded into memory at x6013.