Thing 1 & Thing 2 of Computing: Part II

RepresentingText
Source: www.bbc.co.uk/education/guides/zpfdwmn/revision/1

In Part I, I talked about how actions and commands are translated to Binary. In this article, I am going to discuss how commands and actions are saved in memory and executed by CPU.

Using Computer Memory to save commands

We are going to talk about two types of memories primarily- short term (RAM) and long term (hard disk.)

How is information stored as 0 and 1 inside a RAM (Random Access Memory)?

Using Electric Charge. As we discussed earlier, 0 and 1 stand for presence and absence of something, in the case of the main memory or RAM it is an electric charge. Therefore, RAM gets flushed when electric supply is stopped. RAM is a fast access memory, and it takes the same amount of time to read or write from a memory location independent of its physical location. Two widely used types are SRAM, which is the faster of the two and is used mostly as Cache. DRAM is the other type.

How is information stored as 0 and 1 inside a Hard Drive?

Using Magnetism. Why magnetic and not electric? It is simply because we need to retain the information even when we switch the power off. This is also the reason why we can walk around with internal and external hard drives and just connect it to any computer without data loss. Imagine your hard disk as a book written in Braille, with a raised dot as 1 or no dot as 0. So, if your computer has a 10 GB hard drive, imagine it divided into millions of tiny pieces of information with each piece representing a bit. Each bit can be independently magnetized or demagnetized. And that’s pretty much how data is saved in hard drives.

So far we know that when we create a simple text file and how it gets saved to the memory in series of 0’s and 1’s. ACSII codes let us map each alphabet to a number. E.g A is 65, B is 66 and so on and so forth. Consider the text below and observe its translation to bits.

I love Computer Science

Will get translated to 0010101010100111101010 and this is how it gets saved in the memory.

There are other types of memories as well – temporary memory using registers, fast access Cache memory, virtual memory, etc. We now have a good understanding of memories and storage options, but what about command execution? Let’s get a layer deeper, into CPU.

CPU aka ‘The Brain of a Computer.”

CPU or a processor or a Motherboard is an electric circuit mainly made up of logical transistor gates. Modern CPU’s can have billions of them, but for a very basic CPU, these logical gates alone can do all the necessary logic. CPU is a typical machine which reads an instruction code and executes the instruction.

Let’s get a little more technical – consider a 2-bit CPU. The bitsy information tells us that the registers, data buses, and address buses used are of size 2 bits, which means there are four possible values that it can be stored. So the RAM will be mapped to 4 physical address spaces. There is a mandatory register called Program Counter that keeps tab of the next instruction to be carried out. Think of registers as a memory spots.

RAM
Address Data
00
01
10
11

Let’s say we want our CPU to add two numbers. We can call it 00 in machine code. Instruction table saves this mapping. Let’s build a fictitious instruction set table for our 2 bit CPU.

Instruction Table
ADD Add two numbers and save the result in destination
MOV Move from source to destination
HLT Stop
Instruction Map
0 1
0 ADD MOV
1 HLT

Translation of a program to add two numbers will look like: 00 01 10 11

Where 00 is ADD instruction, 01 and 02 are the memory addresses of 2 numbers to be added, and 11 is the memory address of the destination. Program counter will read 00 and know that it needs to ADD. Since it is an ADD operation, CPU knows that the next two readings will have the numbers to be added followed by the destination. CPU will keep incrementing PC and keep executing instructions till the PC read 10 for HLT. This is how a program is executed using CPU.

In my next article, I am going to discuss how Binary gets translated to Hardware Instructions? If you have questions in the meantime, please feel free to reach out to info@ktlsolutions.com. Don’t forget to check out Part I.


MINAL WAD | .Net Developer

Ever since Minal joined KTL Solutions in March 2008, she has been diligently working as a Business Solutions Developer, providing customized software that integrates with Dynamics GP. She has a passion for using technology to solve real world problems, and it is this passion that enables her to deliver projects with exceptional quality, in time and within budget. Her role as a business analyst is a new found skill, and she has been able to successfully demonstrate it in some of her recent projects. She is proficient in C#, ASP.Net, SQL Server, SharePoint, WPF, Entity Framework, MVVM and Database Design. Minal has over 10 years of experience as a developer. Prior to KTL, she worked with Microsoft in Fargo, ND, where she was a part of Dynamics Axapta team. She holds a Master’s Degree in Computer Science from Oklahoma State University. She involves herself in training and certifications that keeps her abreast with new technologies.

Share this post

Related Posts

Checking Your CMMC Progress

Written by Alec Toloczko With Cybersecurity Maturity Model Certification (CMMC) requirements on the horizon, it’s crucial for organizations handling Controlled Unclassified Information (CUI) to adhere

Read More »