Code Monkey home page Code Monkey logo

ibm701emulator's Introduction

IBM701Emulator

Created By Jason Gallagher

CS T480 - History of Computing

This emulator simulates an IBM 701, originally known as the Defense Calculator. The IBM 701 was IBM's first commercial scientific computer. This computer was announced on April 29, 1952 and its main purpose was to aid in the development of military aircrafts to be used in the korean war. For more information see: https://en.wikipedia.org/wiki/IBM_701

Emulator commands

Command Description Help menu ------------

ppc - print program pointer details

sv - save next binary input into current memory location

ex - executes instruction in current register

help - show this menu

pm - print memory contents from -10 to +10 address's around the current address

op - prints a list of the accepted opcodes. To enter an opcode just type the opcode and the v

file - opens up a file, for relative directory type ./file_name

quit - exits the emulator

save - save contents of the memory registers

jump # - this command followed by a number will jump the program counter to that memory address

run - executes instructions continuously displaying the register contents each execution. Type ctrl-z to stop execution.

Architecture:

Memory:

*72 williams cathode tubes, 1024 bits each
	
    *2048 words
	
    *36 bit words

Instructions:

*18 bits long
	
    * 1 sign bit
	
    * 5 bit opcode
	
    * 12 bit address

Program Accessible Registers:

* accumulator: 38 bit

* multiplier/quotient: 36 bits

Program commands:

Help menu ------------

ppc - print program pointer details

sv - save next binary input into current memory location

ex - executes instruction in current register

help - show this menu

pm - print memory contents from -10 to +10 address's around the current address

op - prints a list of the accepted opcodes. To enter an opcode just type the opcode and the value of the instruction

file - opens up a file, for relative directory type ./file_name

Instructions:

0000 STOP Stop and Transfer Halt; restart address = addr

00001 TR Transfer Jump to (addr)

00010 TR OF Transfer on Overflow if overflow, jump to (addr)

00011 TR + Transfer on Plus if ACC greater than or equal to 0, jump to (addr)

00100 TR 0 Transfer on Zero if ACC = 0, jump to (addr)

00101 SUB Subtract ACC = ACC - MEM(addr)

00110 R SUB Reset and Subtract ACC = 0 - MEM(addr)

00111 SUB AB Subtract Absolute Value ACC = ACC - ABS(MEM(addr))

01001 ADD Add ACC = ACC + MEM(addr)

01010 R ADD Reset and Add ACC = MEM(addr)

01011 ADD AB Add Absolute Value ACC = ACC + ABS(MEM(addr))

01100 STORE Store MEM(addr) = ACC

001101 STORE A Store Address MEM(addr)[6..17] = ACC[6..17]

101101 EXTR Extract MEM(addr) = MEM(addr) AND ACC

01110 STORE MQ Store MQ MEM(addr) = MQ

01111 LOAD MQ Load MQ MQ = MEM(addr)

10000 MPY Multiply [ACC,MQ] = MQ * MEM(addr)

10001 MPY ROUND Multiply and Round MPY then ROUND

10010 DIV Divide MQ = [ACC,MQ]/MEM(addr); ACC = remainder

10011 ROUND Round if MQ high bit set, ACC = ACC + 1

10100 L LEFT Long Left Shift shift [ACC,MQ] left addr places

10101 L RIGHT Long Right Shift shift [ACC,MQ] right addr places

10110 A LEFT Accumulator Left Shift shift ACC left addr places

10111 A RIGHT Accumulator Right Shift shift ACC right addr places

##Notes: I haven't been able to thoroughly. For the save command you must type binary, but to enter in an assembly command you just type

Assembly key integervalue

To import a file, type file enter, then type in the path to your file starting with ./ if it is a local path.

#Binary Input:


opcode|address |opcode|address |

101010 101010101010 101010 101010101010

Accumulator


value |S|Q|P|

001101010101010101010101010101010101 0 1 0

Multpilier_quotient:


Value |s|

101010101010101010101010101010101010 1
  • currently the emulator only supports full word addressing, the defense calculator could be toggled from 18 bit words to 36 bit words depending on the use case. This just means each instruction has its own 36 bit memory space.

##Demo: sample.instr - I have provided a sample application which is the source code for the applying the difference engine method, using the equation from our eniac homework.

###To import: file ./sample.instr

To make sure the file was imported correctly type ppc. This displays the console details you would have on the actual machine.

To start the application, copy the first instruction that was imported. This is a transfer instruction that will tak you to the start of the application.you can view the 10 previous and 10 following lines of assembly by running the command pm.

###Commands: sv 100000011000000000000000000000000000 ex

At this point, you simply repeatedly hit ex to execute, and ppc to view the contents of the registers.

ibm701emulator's People

Contributors

jayx239 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ibm701emulator's Issues

sv command does not work

The sv command, even the one copied from the readme, does not appear to function. The following occurs on my system:

Enter a command: sv 100000011000000000000000000000000000
16: 111111111111111111111111111111111111spot▒╩Üc▄ε

The below modification to the code appears to fix things:

    else if(memcmp(buff,"sv",2) == 0)
    { 
		char instruction_string[WORD_SIZE];
		memset(instruction_string, 0, WORD_SIZE);
		if (read_size > 3)
		        memcpy(instruction_string, buff+3, WORD_SIZE < read_size-3 ? WORD_SIZE : read_size-3);
	  
		int *byte_value;
		byte_value = (int*) malloc(WORD_SIZE*sizeof(int));
		byte_value_from_string(instruction_string,byte_value,WORD_SIZE);
		for(int i=0; i<WORD_SIZE; i++)
			Machine_Memory[pc.current_address][i] = byte_value[i];

		set_address(&pc,pc.current_address,Machine_Memory);
		free(byte_value);
		char* memory_value = (char*) malloc(WORD_SIZE);
		byte_value_to_string(Machine_Memory[pc.current_address], memory_value, WORD_SIZE);
		fprintf(stdout, "%d: %s\n",pc.current_address, memory_value);
		free(memory_value);
    }

ppc register printing outputs noise

I find that running ppc outputs noise after the register values.

Enter a command: ppc
Current Address: 16
Offset: 0
Address Word: 000000000000000000000000000000000000spotIè9♦[ò
Instruction: 000000000000000000ram FiKè9♠Zò
Multiplier Quoticent: 000000000000000000000000000000000000spotⁿè8░[ò
Accumulator: 00000000000000000000000000000000000000R=Lè9☺[ò
Accumulator Int: 0
Multiplier Qotient: 0
Combined Int: 0

Adding length limitations to the string format codes fixed this issue on my system. It appears the strings are not null terminated.

void print_pc(struct program_counter pc)
{

    printf("Current Address: %d\n", pc.current_address);
    printf("Offset: %d\n", pc.offset);

    char* address_word = malloc(WORD_SIZE);
    byte_value_to_string(pc.address_word, address_word, WORD_SIZE);
    printf("Address Word: %.*s\n", WORD_SIZE, address_word);

    char* instruction_string = malloc(INSTRUCTION_SIZE);
    byte_value_to_string(pc.instruction, instruction_string, INSTRUCTION_SIZE);
    printf("Instruction: %.*s\n", INSTRUCTION_SIZE, instruction_string);

    byte_value_to_string(pc.multiplier_quotient, address_word, WORD_SIZE);
    printf("Multiplier Quoticent: %.*s\n", WORD_SIZE, address_word);

    char* accumulator_string = (char*) malloc(ACCUMULATOR_SIZE);
    byte_value_to_string(pc.accumulator, accumulator_string, ACCUMULATOR_SIZE);
    printf("Accumulator: %.*s\n", ACCUMULATOR_SIZE, accumulator_string);    

    printf("Accumulator Int: %lld\n",signed_byte_value(pc.accumulator,ACCUMULATOR_SIZE));
    printf("Multiplier Qotient: %lld\n",signed_byte_value(pc.multiplier_quotient, MULTIPLIER_QUOTIENT_SIZE));

    printf("Combined Int: %lld\n\n",compute_multiplier_accumulator(&pc));

    free(address_word);
    free(instruction_string);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.