CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5%...

14
CS334: Number Systems&& Mars simulator Lab 1_2

description

Ins.Ebtesam AL-Etowi Contents: Exercises && HW solution. Mars simulator.

Transcript of CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5%...

Page 1: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

CS334: Number Systems&& Mars

simulator Lab 1_2

Page 2: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Ins.Ebtesam AL-Etowi

Quizzes/Participation/Absence 5%

Logisim/MIPS Programming 5%

CPU Design Project 10%

Email: [email protected]

Website: http://ebtesamal-etowi.weebly.com

cs334

Page 3: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Ins.Ebtesam AL-Etowi

Contents:•Exercises && HW solution.•Mars simulator.

Page 4: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Ins.Ebtesam AL-Etowi

Perform the binary subtraction. Did signed overflow occur? determined whether or not overflow occurred.11101000 11101000-00010011

Perform the binary addition. Did signed overflow occur? determined whether or not overflow occurred.

0110111000011010

Exercises

10001000

11101010111101101+

discarde

solution

• You are given the following two numbers in two’s complement representation:

Page 5: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Ins.Ebtesam AL-Etowi

solution

16 Bit Binary Hexadecimal Decimal1111111100111100 0xFF3C -196

1111 1111 1000 1000 0xFF88 -1201111111110000000 0xFF80 -128

1111111111111010 0XFFFA -6

0000000000010001 0x0011 171111111111100111 0xFFE7 -25

H.W solution

Page 6: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Ins.Ebtesam AL-Etowi

simulator Mars 4.2

Download the Mars simulator from http://www.cs.missouristate.edu/MARS/

Step 1:

Step 2: Launch the Mars simulator.

Step 3: Click on the Edit tab on the top left (in this pane, you'll see your assembly language program. Well, after you've created it).

Step 4: Go to File and click on New, to start a new program.

Step 5: Let's start with a simple program.

Page 7: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Ins.Ebtesam AL-Etowi

Page 8: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Ins.Ebtesam AL-Etowi

MIPS assembly language

• Registers

32 general-purpose registers

register preceded by $ in assembly language instruction• Program Structure

data declaration section followed by program code section

Page 9: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Ins.Ebtesam AL-Etowi

Cont..))MIPS assembly language

• Data Declarations

placed in section of program identified with assembler directive .data

• Code

placed in section of text identified with assembler directive .text

contains program code (instructions).

Page 10: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Cont..))MIPS assembly language

Ins.Ebtesam AL-Etowi

• Commentsanything following # on a line # This comment

• Data Declarationsformat for declarations: name: storage_type value(s(

example var1: .word 3 # create a single integer variable with initial value 3

Page 11: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Ins.Ebtesam AL-Etowi

• Arithmetic Instructionsmost use 3 operands. all operands are registers; no RAM or indirect addressing. operand size is word (4 bytes).

Cont..))MIPS assembly language

Page 12: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Ins.Ebtesam AL-Etowi

General Example

Page 13: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Ins.Ebtesam AL-Etowi

Page 14: CS334: Number Systems Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%

Ins.Ebtesam AL-Etowi