1. Overview

In this tutorial, we’ll discuss the basics of computer programs and instructions. We’ll also present the core differences between them.

2. What Is a Computer Program?

A computer program consists of a set of instructions in an ordered sequence in order to execute some user-specified tasks. Programs are generally stored in the main memory. A computer executes one instruction at a time.

Computer programs are also known as software applications. We generally write programs using programming languages. Programming languages offer an easy and friendly interface to write computer codes. Using a computer programming language, we can write a computer program that is understandable by humans.

A computer can’t execute high-level code. It only understands binary machine code. Hence, a computer first converts the high-level codes into binary machine-executable codes. Finally, the computer executes the binary machine-executable codes and performs the task specified by the user:

dssds

We can divide computer programs into two categories: interactive and batch programs.

An interactive user provides input to an interactive program. The user can manage, modify, and manipulate data while the program is in a running state. Most of the software programs are interactive in nature as they need some interaction from the user in order to operate smoothly. An example of an interactive program is a web browser.

On the other hand, a batch program can run without any user data. This type of program doesn’t need any interaction from the user. A batch program stops automatically when it completes execution.

A major disadvantage is that all the data and information needed to execute a certain task must be coded in advance. An example of a batch program is a printing application.

3. Introduction to Computer Instructions

Now we know computers can only understand binary machine codes. Computer instruction is a set of binary machine understandable code which is executed by a CPU. It contains the steps which tell the CPU to do a specific task.

For example, we need to specify each step to draw a square on a computer screen. The computer will execute each step one by one:

forward 50
right 90
forward 50
right 90
forward 50
right 90
forward 50

The output would be:

dsfdsf

In general, modern computers contains a 16-bit instruction register (IR). Each instruction consist of 3 fields: mode, opcode, and address field:

dffdh

The mode field defines how a computer can locate the operand. The opcode or operation code field describes the operations to be executed by the CPU. Finally, the address field contains the address of the operand, like memory location or register address.

We can be divide computer instructions into \mathbf{3} categories based on the code format: memory, register, and input/output reference instruction.

In the memory reference instruction, we use 12 bit to specify the memory address, 3 bit for the opcode, and 1 bit for setting the mode as indirect addressing mode:

dffdh 2

In the register reference instruction, the instructions are executed on the register. Moreover, it contains a 12 bit register operation address. Out of the remaining 4 bit, 3 bit is used for the opcode, and 1 bit is utilized for setting the mode:

dffdh 3

Finally, input/output instruction is used for communication between the environment and the computer. Moreover, it contains a 12 bit input/output operation address. Out of the remaining 4 bit, 3 bit is used for the opcode, and 1 bit is utilized for setting the mode:

dffdh 4

4. Differences Between Program and Instruction

At this point, we know the fundamentals of computer programs and instructions. Now let’s discuss the core difference between them:

Rendered by QuickLaTeX.com

5. Conclusion

In this tutorial, we discussed the fundamentals of computer programs and instructions with examples. We also presented the core differences between them.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.