10
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Machine Language Machine Language Apps O/S Arch Arch Logic Digital Analog Devices Physics

Machine Language

Embed Size (px)

DESCRIPTION

Apps. O/S. Machine Language. Arch. m Arch. Logic. Digital. Analog. Devices. Physics. Assembly Language  Computer?. A computer, at its most basic level, needs instruction using a set of bits. - PowerPoint PPT Presentation

Citation preview

Page 1: Machine Language

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Machine LanguageMachine Language

AppsApps

O/SO/S

ArchArch

ArchArch

LogicLogic

DigitalDigital

AnalogAnalog

DevicesDevices

PhysicsPhysics

Page 2: Machine Language

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Assembly Language Assembly Language Computer? Computer?

• A computer, at its most basic level, needs instruction using a set of bits.

• How do we translate concepts such as “add” into a language the computer understands (machine code)?

Page 3: Machine Language

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Instruction EncodingInstruction Encoding• Instruction set architecture also defines the mapping of

assembly instructions to machine code

add 1 2 3

Page 4: Machine Language

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Instruction FormatsInstruction Formats• In every architecture, there is a set of basic formats that

most of their instructions follow.• In LC2K7, for example:

– R-type instructions (Register type – and, nand)

– I-type instructions (Immediate type – lw, sw, beq)

Page 5: Machine Language

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Instruction EncodingsInstruction Encodings• In order to construct these instructions, we need to

translate the information in an assembly statement.

• Opcode: encoded as special codes for each operation– add (000), nand (001), lw (010), sw (011), beq (100), jalr

(101), halt (110), noop (111)• Register Values: Just encode the register number

– r2 = 010 , etc.• Immediate Values: Just encode the value

– remember to fill up the allotted bits!

Page 6: Machine Language

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Encoding ExampleEncoding Examplenand 7 3 4

Page 7: Machine Language

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Encoding ExampleEncoding Example lw 5 2 -8

Page 8: Machine Language

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Instruction Encoding RegularityInstruction Encoding Regularity• Instruction set architecture also defines the mapping of

assembly instructions to machine code

add 1 2 3

Page 9: Machine Language

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Encoding – Your TurnEncoding – Your Turn• Compute the encoding (give the hex) for:

– add 3 7 3 (opcode for add is 000)– sw 5 1 67 (opcode for sw is 011)

Page 10: Machine Language

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Encoding – Your Turn, part IIEncoding – Your Turn, part II• Compute the encoding (give the hex) for:

– beq 3 4 top (opcode for beq is 100)

– The beq is on line 217– The label top appears on line 222