#include "sim-signal.h"
\f
/* Get the register number from the number. */
-static unsigned16
-register_num (SIM_CPU *cpu, unsigned16 num)
+static uint16_t
+register_num (SIM_CPU *cpu, uint16_t num)
{
SIM_DESC sd = CPU_STATE (cpu);
}
/* Helper to process immediates according to the ISA. */
-static unsigned16
-interp_num (SIM_CPU *cpu, unsigned16 num)
+static uint16_t
+interp_num (SIM_CPU *cpu, uint16_t num)
{
SIM_DESC sd = CPU_STATE (cpu);
void step_once (SIM_CPU *cpu)
{
SIM_DESC sd = CPU_STATE (cpu);
- unsigned16 iw1, num1;
+ uint16_t iw1, num1;
sim_cia pc = sim_pc_get (cpu);
iw1 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc);
else if (num1 == 1)
{
/* set: 1 a b: Set register <a> to the value of <b>. */
- unsigned16 iw2, iw3, num2, num3;
+ uint16_t iw2, iw3, num2, num3;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = register_num (cpu, iw2);
else if (num1 == 2)
{
/* push: 2 a: Push <a> onto the stack. */
- unsigned16 iw2, num2;
+ uint16_t iw2, num2;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = interp_num (cpu, iw2);
{
/* pop: 3 a: Remove the top element from the stack and write it into <a>.
Empty stack = error. */
- unsigned16 iw2, num2, result;
+ uint16_t iw2, num2, result;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = register_num (cpu, iw2);
{
/* eq: 4 a b c: Set <a> to 1 if <b> is equal to <c>; set it to 0
otherwise. */
- unsigned16 iw2, iw3, iw4, num2, num3, num4, result;
+ uint16_t iw2, iw3, iw4, num2, num3, num4, result;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = register_num (cpu, iw2);
{
/* gt: 5 a b c: Set <a> to 1 if <b> is greater than <c>; set it to 0
otherwise. */
- unsigned16 iw2, iw3, iw4, num2, num3, num4, result;
+ uint16_t iw2, iw3, iw4, num2, num3, num4, result;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = register_num (cpu, iw2);
else if (num1 == 6)
{
/* jmp: 6 a: Jump to <a>. */
- unsigned16 iw2, num2;
+ uint16_t iw2, num2;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = interp_num (cpu, iw2);
else if (num1 == 7)
{
/* jt: 7 a b: If <a> is nonzero, jump to <b>. */
- unsigned16 iw2, iw3, num2, num3;
+ uint16_t iw2, iw3, num2, num3;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = interp_num (cpu, iw2);
else if (num1 == 8)
{
/* jf: 8 a b: If <a> is zero, jump to <b>. */
- unsigned16 iw2, iw3, num2, num3;
+ uint16_t iw2, iw3, num2, num3;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = interp_num (cpu, iw2);
else if (num1 == 9)
{
/* add: 9 a b c: Assign <a> the sum of <b> and <c> (modulo 32768). */
- unsigned16 iw2, iw3, iw4, num2, num3, num4, result;
+ uint16_t iw2, iw3, iw4, num2, num3, num4, result;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = register_num (cpu, iw2);
{
/* mult: 10 a b c: Store into <a> the product of <b> and <c> (modulo
32768). */
- unsigned16 iw2, iw3, iw4, num2, num3, num4, result;
+ uint16_t iw2, iw3, iw4, num2, num3, num4, result;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = register_num (cpu, iw2);
else if (num1 == 11)
{
/* mod: 11 a b c: Store into <a> the remainder of <b> divided by <c>. */
- unsigned16 iw2, iw3, iw4, num2, num3, num4, result;
+ uint16_t iw2, iw3, iw4, num2, num3, num4, result;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = register_num (cpu, iw2);
else if (num1 == 12)
{
/* and: 12 a b c: Stores into <a> the bitwise and of <b> and <c>. */
- unsigned16 iw2, iw3, iw4, num2, num3, num4, result;
+ uint16_t iw2, iw3, iw4, num2, num3, num4, result;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = register_num (cpu, iw2);
else if (num1 == 13)
{
/* or: 13 a b c: Stores into <a> the bitwise or of <b> and <c>. */
- unsigned16 iw2, iw3, iw4, num2, num3, num4, result;
+ uint16_t iw2, iw3, iw4, num2, num3, num4, result;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = register_num (cpu, iw2);
else if (num1 == 14)
{
/* not: 14 a b: Stores 15-bit bitwise inverse of <b> in <a>. */
- unsigned16 iw2, iw3, num2, num3, result;
+ uint16_t iw2, iw3, num2, num3, result;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = register_num (cpu, iw2);
else if (num1 == 15)
{
/* rmem: 15 a b: Read memory at address <b> and write it to <a>. */
- unsigned16 iw2, iw3, num2, num3, result;
+ uint16_t iw2, iw3, num2, num3, result;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = register_num (cpu, iw2);
else if (num1 == 16)
{
/* wmem: 16 a b: Write the value from <b> into memory at address <a>. */
- unsigned16 iw2, iw3, num2, num3;
+ uint16_t iw2, iw3, num2, num3;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = interp_num (cpu, iw2);
{
/* call: 17 a: Write the address of the next instruction to the stack and
jump to <a>. */
- unsigned16 iw2, num2;
+ uint16_t iw2, num2;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = interp_num (cpu, iw2);
{
/* ret: 18: Remove the top element from the stack and jump to it; empty
stack = halt. */
- unsigned16 result;
+ uint16_t result;
TRACE_INSN (cpu, "RET");
cpu->sp += 2;
else if (num1 == 19)
{
/* out: 19 a: Write the character <a> to the terminal. */
- unsigned16 iw2, num2;
+ uint16_t iw2, num2;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);
num2 = interp_num (cpu, iw2);
to <a>. It can be assumed that once input starts, it will continue
until a newline is encountered. This means that you can safely read
lines from the keyboard and trust that they will be fully read. */
- unsigned16 iw2, num2;
+ uint16_t iw2, num2;
char c;
iw2 = sim_core_read_aligned_2 (cpu, pc, exec_map, pc + 2);