7. Implementing a single computer

Source: Internet
Author: User

The previous implementation of a number of addition/subtraction, counters, memory. Here we are going to use these results to implement a new, better-used adder. People are lazy, so if you want to add 100 numbers to the adder that you implemented earlier, this is very bad, because if there is an error in the middle step, you need to clear 0 and re-enter it again. So we can make use of the first storage and post-access features of RAM, write the values that need to be added to the memory, and then take it out as an input to the adder.

Here we assume that we are using a 64k*8ram,16 bit counter, a 8-bit adder, and a latch. Writes 100 numbers to the memory not much said, through the counter can start from 0000h one to take out the data, and as the adder input. However, there are the following disadvantages:

(1) How to achieve the addition of more digits. It is not reasonable to extend the bit width of the device.

(2) How to stop it. Will indefinitely continue to be calculated, and may loop to repeat the accumulation.

(3) How to achieve a specific number of additions in 100 numbers.

The third problem is better solved, because only the output of the accumulator is written to ram and not shown in the bulb.

The second problem is also easy to solve, is to introduce a code of RAM, stored in a digital code, we can pre-set some digital code, such as load (10h), Store (11h), Add (20h), Halt (FFh), so that when there is Halt stop.

The input to the 8-bit latch can have two options, the first being read from RAM, or load, and the second being read from the adder, which is Add.

We can embed the addition and subtraction devices into the inside, so that the addition and subtraction can be achieved.

The first question is whether we can solve it. Of course. We can use the low byte to start the operation, and then the high byte, because the high-bit byte needs to contain low-byte carry problem, this introduces an operation called carry addition.

So we have 7 instructions:

1. Load

2. Store

3. Add

4. Add with Carry

5. Subtract

6. Subtract with Borrow

7. Halt

However, the calculation of these numbers in turn is not very good, the disadvantages are as follows:

(1) For example, a number of 1234h, then 12 and 34 are separated, the address is discontinuous.

(2) The previous result is not allowed. Because of the use of counters, so can only add, not minus.

For both of these issues, we use a fixed-length instruction that has 3 bytes for one instruction (except halt), a numeric code for the first byte, and a 16-bit address for the second third byte, such as load 1000h.

We introduced three latches as output of the code RAM, storing the three bytes respectively, and two bytes of data as input to the RAM, so that both the previous data and the 16-bit data can be stored continuously.

We use two RAM here, in fact we do not need to use two RAM, the value needs to distinguish whether to take the data or take instructions, which requires 2-1 selectors. Since we can only keep the execution of the instructions, this has brought us a lot of inconvenience, so introduced the jump command, but not stop jumping, so the introduction of conditional jump instructions. For example, non-0 jump, a number of each with halt (FFH), which is equivalent to minus 1, minus 0 will not jump.

Now that we have finished a computer, the difference between a calculator and a computer is the ability to control repetition and looping.

Digital computers and analog computers

The computer consists of 4 parts: the processor (addition and subtraction), the memory (RAM), the input (switch), and the output device (bulb).

This shows that a computer is constructed.

As we said earlier, for example, FFH belongs to machine code, and Halt is a mnemonic, that is, assembly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.