Home > Sample essays > Dive into Computer Language Types & Programming

Essay: Dive into Computer Language Types & Programming

Essay details and download:

  • Subject area(s): Sample essays
  • Reading time: 9 minutes
  • Price: Free download
  • Published: 1 April 2019*
  • Last Modified: 23 July 2024
  • File format: Text
  • Words: 1,214 (approx)
  • Number of pages: 5 (approx)

Text preview of this essay:

This page of the essay has 1,214 words.



Controlled Assessment Section 1

Introduction

In this controlled assessment I will be talking about different types of computer languages, such as high-level languages. I will also discuss the advantages and disadvantages of different processor chips.

High Level Programming Languages

A high level programing language is a computer language that is very close to how we communicate (human language). This type of computing language makes creating a program much easier and simpler. To make this process of creating a program  easy a high level language uses

• Variable; a value that changes depending on the information which is passed to a program or conditions which are written into the program

• Array;  a variable that has been indexed

• Object; an object holds data and how to manipulate that data.  Often referred to as a class

• Class;  a template for holding an object

• Function;  a routine which returns a value

• Procedure;  performs an operation but does not return a value, sometimes also referred to as a function

• Loop; this is a series of instruction which are repeated until a set condition is met

A few examples of high level programing languages are Python, Perl and Ruby.

Machine Code

Machine code is a set of instructions executed directly by a computer’s CPU.  Each instruction performs a specific task, such as a load operation on a unit of data in a CPU register or memory.  Every program executed by a CPU is made up of a series of these instructions.

Assembly Languages

An assembly language is an example of a low level language. It is used by the LMC (Little Man Computer). There are very strong similarities between the actual language and the architectures machine code instructions. The language still needs to be converted into machine code by an assembler.

The relationship between machine code and binary

Machine code and binary are the same format (a number system with base 2) which is either a 1 or 0. But machine code can also be expressed as a hexadecimal (base 16). The binary system and hex are very interconnected with each other, it’s simple to convert from binary to hex and convert back vice versa. And because hex is much more readable and useful than binary – it's often used and shown instead.

Comparison between Python and the LMC assembly languages

Python is high level general purpose programming language that can be used by most inexperienced programmers to complete a successful program, an example would be the ‘hello world’ program:

Print “Hello, World!”

The LMC is an instructional model of a computer used in the educational environment to introduce students to a programing language closer to machine code.  Programs like “Hello, World!” can not be created in LMC as it can only output numbers under 1000.

Fetch-execute cycle

This is the sequence of actions that a CPU performs to execute each machine code instruction in a program. This includes fetching instructions from the memory, decoding them and running them.

Instruction sets

A complete set of machine code instructions that can be recognised and executed by the CPU

Opcodes and operands

• Opcode is short for operation codes. These are simple instructions that can be executed by the CPU. In machine code it is binary or hexadecimal loaded into the instruction register

• Operands are manipulated by the opcode

1.  (a) Explain the Purpose of the given code

def mystery(n):

a, b = 0, 1

while a < n:

print (a)

a, b = b, a + b

The code shown above is for a Fibonacci sequence. A Fibonacci sequence is a sequence of numbers where, when you add the previous two numbers in the sequence it gives you the next number in the sequence. The new number is then used to give the next number in the sequence and so on.

What does the code do?

Line 1: ‘def.’ defines the variable ‘mystery’ which is the first number in the sequence

Line 2: Gives a value to the variables ‘a, b’

Line 3: ‘while’ is a function and starts a loop, this loop will only end when the value of a reaches the value of ‘’n’

Line 4: This line prints the current value of ‘a’

Line 5: Adds the value of ‘a’ and ‘b’ to give the new value of ‘a’

1 (b) Code as a Flowchart

1 (c) As it stands, this code will not run. Add extra Python code in order to make it run on your computer.

1 (d) Plan, run and dry run of LMC program

The little man computer (LMC) is a mode (a setting in a computer program) of computer. The idea is that there is a man inside a room that has 100 mailboxes to store data and instructions in. The LMC is used to teach students because it has all the basic instructions of a normal computer.  There are several parts to a LMC:

• Mailbox- where the data is stored

• CPU- this carries out instructions

• Register- somewhere were a value is held when it is being processed

• Program counter- displays and counts which task the CPU is doing

• Instruction register- All the instructions you can tell the LMC to do

• Address register- stores the location of different data

• Accumulator- stores a numerical value

• Arithmetic Unit- where all the addition and subtraction takes place

In the following LMC program I will instruct the LMC to run the Fibonacci sequence, the program will only output ten iterations. I will do this by creating a loop using a branch (if positive or zero) and a series of additions to create the required results.

Plan

Explain what the above plan means???????

Dry run

a b

0 1 a, b = a, a + b

1 1

1 1 2

2 2 3

3 3 5

4 5 8

5 8 13

6 13 21

7 21 34

8 34 55

9 55 89

10 89 144

0 1 1 2 3 5 8 13 21 34 55 89

Iteration: 1 2 3 4 5 6 7 8 9 10

1 (e)  Code and test this program.

Attempt 1:

EXPLAIN THINKING AROUND THIS AND WHAT IS THE PROGRAM BELOW DOING?

Testing Results

Creates a continuous loop and only outputs ‘1’.

Improvements

To improve the above program a more complex adding and saving process will have to be introduced.   This will

Attempt 2:

Explain what you have changed below from Attempt 1

Testing Results

Program adds A and B then outputs but doesn’t change the value of A

Improvements

. To improve…

Attempt 3:

Test Results

Problem Unknown

Improvements

Attempt 4:

Testing Results

Fibonacci works but the number of iterations is wrong (only does it 8 times).

Improvements

To improve I need to add a value (1 or 2) to the total number of iterations.

Attempt 5:

Test Results

Needs anouther itteration!

Improvements

Added another iteration to the program

Attempt 6:

Test Results

Program has passed testing and meets requirements.

Program showing how the LMC can run the Fibbonacci sequence

1 (f) Change the program so that the number of iterations can be controlled by the user.

1 (g) Test this program.

2.  (a) Explain LMC multiplication

As there is no direct multiplication instruction for the LMC you have to use a more complicated method.  To achieve a multiplication with the LMC you need to create a loop that adds a number for x times. E.g. 5 x 4 = Loop 5 times (4+4). This loop can be achieved by using a ‘branch if positive’ function.

DRY RUN

2 (b) Plan of LMC Multiplication Code

2 ( c) The Program!

LMC PROGRAM MISSING HERE

TESTING RESULTS HERE 

3. (a) Explain the Program

This code defines a bitwise shift left of 2 characters (It adds an extra zero to the right hand side of the bitwise representation of the number stored as the value of the variable ‘temp’). Therefore by putting in << = Y we are saying shift left by 2 characters, so we go from an original binary of 1110 (14 in decimal which is the ‘Var Temp’ value) to the new Binary = 111000 (decimal answer = 56) by shifting left by 2.

3 (b) Explain what ‘y’ does

Changing the value of y will give us:

Y=3…shifts 3 characters left (Binary = 1110000 – decimal = 112)

Y=4…shifts 4 characters left (binary = 11100000 – decimal = 224)

3 (c) Plan and write a LMC program with the same results

Plan

LMC Program

Code

4.  Evaluation

In this controlled assessment I have studied how low level processor operations work, how they compare to higher level operations and the relationship between mnemonics and assembly language.  I now understand how a high level programming language (python) can be translated into a lower level programming language (LMC).  I also have learnt how to perform a simple loop in a LMC code to perform a multiplication of two numbers.  JavaScript was another programming language which, thanks to various types of research that I conducted, I can now understand and interpret (the code).

Throughout this project I found many things difficult, and had to adapt how I would normally find information to overcome these problems, mentioned in the following .One of the problems I found challenging was the logic for how my Fibonacci code was going to work.. I overcame this problem by discussing solution with my teacher and writing potential codes on paper, using trial and error.  These codes and notes can be seen in the attached papers.  Another key difficulty whilst completing the project was understanding what the JavaScript program did.  This was particularly hard as we had not covered this in any previous lesson.  By doing some online research and asking an IT professional, I managed to slowly figure out what the different functions meant which eventually led to me being able to interpret the whole code as a whole.  I also believe that this will aid me in any future tasks that include JavaScript.  

A minor difficulty I faced in the project was how to write the LMC multiplication code.  This difficulty was very easy to overcome.  I did this by simply writing different versions of code, again I used ‘trial and error’, testing each iteration, to achieve a successful look and data storage system that outputted the multiplication of two different (or the same) numbers.

I participated in some other general activities to help me understand multiple errors and small mistakes that I made whilst writing my project up.  This also helped with adding small details to the tasks.  This included spending multiple hours inside of my local library, reading up on certain articles inside of the OCR specification to aid my knowledge around how processor operations work, what they do and different forms of programming languages / styles.  I against asked an IT professional to further aid my knowledge and to help with understanding with completing general practical activities within any project.

5. CISC AND RISC processors

In considering what a chip manufacturer would need to take into account when planning a new microprocessor I have investigated what CISC and RISC processors are and their relative merits and an overview of the downsides.  I will explain what each of these processors is and then compare both, detailing advantages and some disadvantages of CISC and RISC processors.  Finally I will give a brief conclusion of the key points a manufacturer might want to consider in making his decision.

What is CISC?

Complex instruction set computing (CISC) is a CPU design where singe instructions can execute several low-level operations.  E.g. a load from memory and a new memory store.  These are capable of multi-step operations or addressing modes within single instructions.

What is RISC?

Reduced Instruction Set Computer (RISC) can perform a limited set of operations rapidly.  It is based on a type of microprocessor designed to complete operations quickly.

Development of CISC and RISC architectures (google history, timelines)

CISC is the predecessor to RISC and was developed in the q970’s when high level languages such as FORTRAN and Pascal became popular.  The term CISC has been given to this processor after its development to distinguish between its design and the RISC design.  CISC was aimed at enhancing the machines being designed, to help simplify the tasks that a compiler had to do.  This meant that the program was able to achieve its goal in fewer instructions so using less memory, which at the time was expensive.  Some early CISC architectures were the IBM 260 and the DEC PDP-11.

The first RISC processors came from IBM, UC-Berkeley and Stanford universities in the late 1970’s and early 1980’s.  RISC was made to be able to optimise a small set of highly-optimised instructions.  CISC was an established architecture and although RISC architecture was superior in a number of ways there was an unwillingness by manufacturers to move to this architecture as there was a perceived risk of making the change by the manufacturers and there were not believed to be any significant advantages.  This led to process being higher than CISC and therefore non- competitive.

In recent years as computer technologies have advanced the way that RISC uses RAM along with its greater emphasis on software means it is more compatible to today’s manufacturing needs.

Intel’s X86 is the only current chip which uses CISC, and although RISC architecture is now far more competitive other factors have meant that CISC is not being used such as advances in other computer technologies and considerable decreases in the cost of RAM (approx.. 1/1000 of the cost).

How does a CISC processor work

Complex instruction set computing (CISC) is a CPU design where single instructions can execute several low-level operations. E.g. a load from memory and a memory store. These are capable of multi-step operations or addressing modes within single instructions.

Reduced Instruction Set Computer (RISC) can perform a limited set of operations rapidly. It is based on a type of microprocessor designed to compete operations quickly.

The advantages of RISC include:

• An emphasis on software

• Independent instructions like LOAD and STORE

The advantages of CISC include:

• Complex instructions

• Small code sizes

• High cycles per second

RISC processors normally achieve 2 to 4 times the performance of CISC processors. In RISC, the instructions have a runtime of 1 clock cycle each. However, complex instructions in CISC take longer to execute. However, RISC uses a pipelined implementation. This means instruction execution overlaps. So, RISC generally has a faster execution time.

Secondly, instructions on a RISC processor use less space on the chip because the instructions of a RISC processor are simpler in comparison to a CISC processor. This means different functions can be placed on the same chip. Having everything on the same chip means the hardware becomes much simpler. Hence RISC processors are ordinarily cheaper, due to a simpler hardware. On the other hand, CISC processors use more complex instructions. These instructions take up more space on the chip. Accordingly, the overall hardware tends to be more complex in order to harbour features like floating-point operations. As a result, CISC processors are more expensive and more complex than RISC processors.

About this essay:

If you use part of this page in your own work, you need to provide a citation, as follows:

Essay Sauce, Dive into Computer Language Types & Programming. Available from:<https://www.essaysauce.com/sample-essays/2016-4-19-1461057211/> [Accessed 01-05-26].

These Sample essays have been submitted to us by students in order to help you with your studies.

* This essay may have been previously published on EssaySauce.com and/or Essay.uk.com at an earlier date than indicated.