Computer Organization &
Assembly Language LAB MANUAL
LAB MANUAL
Computer Organization &
Assembly Language
NAME: NOOR FATIMA
ROLL NO: 061
DEPARTMENT: BS CS (SSDP)
SUBMITTED TO: SIR USMAN AZIZ
GC WOWEN UNIVERSITY, SIALKOT
1
Computer Organization &
Assembly Language LAB MANUAL
Table of Contents
LAB # 01 ...................................................................................................................................................................... 1
TASK # 01 ................................................................................................................................................................ 1-5
TASK # 02 ............................................................................................................................................................ 5-7
LAB # 02 ...................................................................................................................................................................... 8
TASK #03 ................................................................................................................................................................. 8-9
TASK # 04 ............................................................................................................................................................ 10-13
LAB # 03 ...................................................................................................................................................................... 14
TASK # 05 ................................................................................................................................................................ 14-17
TASK # 06 ............................................................................................................................................................ 18-21
LAB # 04 ...................................................................................................................................................................... 21
TASK #07 ................................................................................................................................................................. 21-24
TASK # 08 ............................................................................................................................................................ 23-25
2
Computer Organization &
Assembly Language LAB MANUAL
------ (LAB Number 1) ------
Task # 1
INTRODUCTION
COMPUTER ORGANIZATION
Computer Organization and Architecture is the study of internal working,
structuring and implementation of a computer system. Architecture
in computer system, same as anywhere else, refers to the externally
visual attributes of the system.
ASSEMBLY LANGUAGE
An assembly language is a low-level programming language
designed for a specific type of processor. It may be produced by
compiling source code from a high-level programming language
(such as C/C++) but can also be written from scratch.
Assembly code can be converted to machine code using
an assembler.
SOFTWARE FOR ASSEMBLY LANGUAGE
Software for assembly language is PCSPIM. It is a software simulator that runs
programs written for MIPS R2000/R3000 processors. SPIM lets you test, and debug
assembly programs written for MIPS. SPIM lets you see the contents of memory and
registers when programs are running, i.e., to see what the instructions are doing.
DOWNLOADING PCSPIM
PCSPIM is a MIPS R2000/R3000 Simulator, available from
http://www.cs.wisc.edu/~larus/spim.html
To run PCSPIM
lab): download the file http://www.cs.wisc.edu/~larus/SPIM/PCSPIM.zip,unzip it
3
Computer Organization &
Assembly Language LAB MANUAL
and run the setup program.
First step to click the setup file which is placed in downloads. Then you must run the
application.
After this the screen appears as: and click the next tab for installing setup.
Next step is to accept the software policy and security instruction.
4
Computer Organization &
Assembly Language LAB MANUAL
After this downloading and installing process for the software started.
Task # 2
RUNNING PCSPIM
Once installed. Start -> Programs ->PCSPIM.
The first time you run PCSPIM you may have the warning box shown
below appear.
Click YES you will then see a screen like this:
At the bottom, under “Trap file:” or “Execution file:”, change the drive
from “C” TO “D”.
Leave “allow pseudocode instructions” checked. Hit OK. You can return
tosettings at any time from the PCSPIM window by selecting
Simulator->Settings.
5
Computer Organization &
Assembly Language LAB MANUAL
WINDOWS APPEAR IN PCSPIM
Four windows appear in the PCSPIM frame: Registers, Text Segment, Data
Segment, and Messages Window.
Register Window: The value of all register in the MIPS CPU and FPU.
Text Segment window: instruction both from your program and the
system code that is loaded automatically when PCSPIM is running.
Data Segment: The data loaded into your program’s memory and the data
of the program’s stack.
Messages Window: for PCSPIM messages. This is where error message
appears.
OPENING, LOADING AND RUNNING A FILE
Use the Notepad and write the code right-click and use “Save target
as” to save it somewhere. And save the file name with double quotation
sign and extensions.
To open the first file: File -> Open.
Open “Task1.s” from wherever you saved it above. In the Message window, you should
see a message “Task1.s” has successfully loaded First try running the program:
Simulator -> Run-OR- (or you can use the button)
You will be asked for the starting address of the program. Use the address of the first
instruction in the Text Segment window. (This is most likely set already)
6
Computer Organization &
Assembly Language LAB MANUAL
Next, try single stepping through the program one step at a time.
Simulation -> Reload <filename>
Then, F-10 to step through one statement at a time.
Step through the program, trying to understand how it works. Watch how the
registerschange.
STOPPING PROGRAM EXECUTION
To stop the execution at any time, you can use Simulation -> Break.
You will be prompted whether to continue or end execution. (Click on Yes to end)
When you make changes to the file you are running Simulation -> Reload
<filename>
to have the updated file loaded into PCSPIM. Quitting PCSPIM->File -> Exit
7
Computer Organization &
Assembly Language LAB MANUAL
------ (LAB Number 2) ------
Task # 3
How to convert hexa-decimal into decimal and decimal into hexa-
decimal in PCSPIM?
Here, I am going to show you how to convert hexa-decimal into decimal and
decimal into hexa-decimal in PCSPIM.
---------- (STEPS) ---------
First, open your PCSPIM and the Click on the option stimulator.
Then, Click Settings……
After that u see a dialogue box like that…
Now, Click the option (general register in
hexadecimal)
8
Computer Organization &
Assembly Language LAB MANUAL
Now, Click OK….
Then it will convert into hexa-decimal
And if you want to again convert into decimal then again go to simulator, click
setting and the again cluck the option (general register in hexa-decimal) and turn it
of……
Now, it again converts into Decimal…….
9
Computer Organization &
Assembly Language LAB MANUAL
Task # 4
What will the program be to add 10 numbers in the assembly
language? Also run the program on PCSPIM.
---------- (STEPS) ---------
First off, all wrote this code on notepad.
After writing code on notepad save file with lab task 4 with. s extension in double
quotation.
Click save……….
10
Computer Organization &
Assembly Language LAB MANUAL
Now we open PCSPIM, Click on the option FILE.
After that, Click the option File and then click the option open.
Choose Your Code that u Write on NOTEPAD.
Now, open it.
Then, IT will LOOK like this on PCSPIM.
Now, CLICK the HAND sign button (Breakpoints)
11
Computer Organization &
Assembly Language LAB MANUAL
Then, write main on the address box.
After, Click the Add
Then, it will look like this.
After that, run the program and give address like this.
Click OK
12
Computer Organization &
Assembly Language LAB MANUAL
---------------- (OUTPUT) ----------------
------ (LAB Number 3) ------
Task # 5
What will the program be to adding 2 numbers in the
assembly language? Also run the program on PCSPIM.
First off, all wrote this code on notepad.
13
Computer Organization &
Assembly Language LAB MANUAL
---------- (STEPS) ---------
After writing this on notepad save the file with. s extension.
Here, we are saving it.
14
Computer Organization &
Assembly Language LAB MANUAL
Now, go to the PSSPIM and click his FILE option and open the code in the PCSPIM.
It will look like this……
Now, CLICK the HAND sign button (Breakpoints) and take your address.
15
Computer Organization &
Assembly Language LAB MANUAL
Click OK….
Again, Click OK….
---------------- (OUTPUT) ----------------
Now, enter number 1 and number 2 and u will find the ADD of 2 numbers.
Here are the results.
16
Computer Organization &
Assembly Language LAB MANUAL
Task # 6
What will the program be to Subtract of 2 numbers in
the assembly language? Also run the program on PCSPIM.
First off, all wrote this code on notepad.
---------- (STEPS) ---------
After writing this on notepad save the file with. s extension
Here, we are saving it.
17
Computer Organization &
Assembly Language LAB MANUAL
Now, go to the PSSPIM and click his FILE option and open the code in the
PCSPIM.
It will look like this……
Now, CLICK the HAND sign button (Breakpoints) and take your address.
Click OK….
18
Computer Organization &
Assembly Language LAB MANUAL
Again, Click OK….
---------------- (OUTPUT) ----------------
Now, enter number 1 and number 2 and u will find the SUBTRACT of 2
numbers.
Here are the results:
19
Computer Organization &
Assembly Language LAB MANUAL
------ (LAB Number 4) ------
Task # 7
What will the program be to multiplication of 2 numbers in the
assembly language? Also run the program on PCSPIM.
First off, all wrote this code on notepad.
---------- (STEPS) ---------
After writing this on notepad save the file with. s extension
Here, we are saving it.
20
Computer Organization &
Assembly Language LAB MANUAL
Now, go to the PSSPIM and click his FILE option and open the code in the
PCSPIM.
It will look like this……
Now, CLICK the HAND sign button (Breakpoints) and take your address.
21
Computer Organization &
Assembly Language LAB MANUAL
Click OK….
Again, Click OK….
---------------- (OUTPUT) ----------------
Now, enter number 1 and number 2 and u will find the SUBTRACT of 2
numbers.
Here are the results:
22
Computer Organization &
Assembly Language LAB MANUAL
Task # 8
What will the program be to take a quotient of 2 numbers in the
assembly language? Also run the program on PCSPIM.
First off, all write this code on notepad.
---------- (STEPS) ---------
After writing this on notepad save the file with. s extension
Here, we are saving it.
Now, go to the PSSPIM and click his FILE option and open the code in the
PCSPIM.
23
Computer Organization &
Assembly Language LAB MANUAL
It will look like this……
Now, CLICK the HAND sign button (Breakpoints) and take your address.
Click OK….
24
Computer Organization &
Assembly Language LAB MANUAL
Again, Click OK….
---------------- (OUTPUT) ----------------
Now, Dividend and Divisor and u will find the Division of 2 numbers.
Here are the results:
25
Computer Organization &
Assembly Language LAB MANUAL
26