dr. chuck cartledgedr. chuck cartledgedr. chuck cartledge...

17
1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization Lecture #012 Sections 5.2 through 5.4, Machine instructions and assemblers Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018 2 July 2018

Upload: others

Post on 24-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

1/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

CSC-205 Computer OrganizationLecture #012

Sections 5.2 through 5.4, Machine instructionsand assemblers

Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge

2 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 20182 July 2018

Page 2: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

2/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

Table of contents (1 of 1)

1 5.2Irritating things aboutdirect addressing

2 5.3How symbols make lifeeasier.

3 5.4Translating from LevelHOL6

4 Chap. 5 reviewAssembly language

5 Conclusion

6 References

Page 3: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

3/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

Irritating things about direct addressing

A simple program.

You (the human) have to know the code (hex) for everything.

Page 4: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

4/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

Irritating things about direct addressing

When do you stop printing a string?

What is difference between C++ string and char[] when printing??

Page 5: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

5/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

Irritating things about direct addressing

Terrific quote

“In all these examples, the instruc-tion simply grinds through the vonNeumann execution cycle. You mustalways remember that the translationprocess is different from the executionprocess and that translation happensbefore execution. After translation,when the instructions are executing,the origin of the bits is irrelevant. Theonly thing that matters is what thebits are, not where they came fromduring the translation phase.”

J. Stanley Warford [3]

J. Stanley Warford

Page 6: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

6/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

How symbols make life easier.

Let the software worry about where things are.

Page 7: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

7/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

How symbols make life easier.

A truly silly program.

The symbol “this” points to memory location0000

Memory location 0000 contains the opcode forDEC0 with OprnSpec “this” and to treat thecontents as decimal

von Neumann starts at address 0000

Loads the instruction

Executes the instruction (outputs the contents atmemory location 0000)

Stops

The opcode is interpreted as data (as per theopcode) and output.

Seems silly, but von Neumann doesn’t distinguish between programand data. Powerful stuff.

Page 8: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

8/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

Translating from Level HOL6

We’ve “bumped” into the idea ofcompilers (nee, translators)before.

Compilers convert HOLdirectly into machine code(ones and zeros), or

Compiler convert HOL inassembler level code thatanother program has totranslate into machine code.

A compiler is a program (albeit,a complex one).

Image from [3].

Page 9: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

9/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

Translating from Level HOL6

Relative sizes of different compilers.

Files from Ubuntu 14.04.2

g++ ⇒ g++-4.8 ⇒775Kbytes

fortran ⇒ 14785Kbytes

javac ⇒ 7KBytes, an ELFfile

Executable and Linkable Format(ELF) tells computer where toget information and where to putit memory

Image from [2].

Page 10: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

10/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

Translating from Level HOL6

Some HOL statements get translated

Statements that actually dosomething get translated:

The cout statement

The return statement

return inside the main() becomesSTOP only in the Pep/8compiler.

What about the other statements??

Page 11: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

11/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

Translating from Level HOL6

Some HOL statements don’t get translated

The “#include <>” is acompiler directive on whereto get additional information

The “using namespace . . . ”is to make typing easier forthe human

The semicolons terminate alogical line

All HOLs have the same types of problems: scoping, brevity, lineendings, line beginings, etc.

Page 12: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

12/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

Translating from Level HOL6

Variables are just named places in memory

About variables:

At the ISA level, they live inmemory

At the ASL level, they are labelsfor memory location

At the HOL level, they exist

There are generally three types ofvariables:

Global – available to everyoneand “remember things”

Local – available to the currentcontext and then lost

Static – available to the currentcontext and then remembered

Other – available to lower contextand then lost

Page 13: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

13/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

Translating from Level HOL6

How to resolve structures and classes?

Remember at the lowest level, there areonly addresses.

“typedef” takes a “known type”and makes a new type

“enum” creates an int, limits thevalues it can assume, and givesthose values names

“struct” names a collection ofcontiguous memory locations

We can now create an array ofcontiguous memory locations of thesame type.

The compiler keeps track of variablenames, types, and locations in memory.

A class is a block of contiguous memory locations that has addresses offunctions inside of it.

Page 14: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

14/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

Translating from Level HOL6

A special type of variable that doesn’t vary.

C++ uses the compilerdirective “const” to tell thecompiler to cause an errorwhen the constant thing ismodified.

Pep/8 uses the “.EQUATE”directive

Usually you’ll use immutable variables for safety anddocumentation purposes.

Page 15: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

15/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

Assembly language

Moving up the “food chain.”

Relationship betweenassembly and machine code,

Pages 194 and 195,

Pep/8 pseudo operators,

Immediate addressing andtrap instructions,

Concept of symbols,

von Neumann, vonNeumann, von Neumann,

Translating from HOL6

Image from [1].

Page 16: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

16/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

What have we covered?

Immediate addressing and the trapinstructionsSymbolsTranslating from level HOL6Chapter review

Next period:

Test, Section 6.1, Assemblers and high order languages

Page 17: Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge ...ccartled/Teaching/2018-Summer/Lectures/… · 1/17 5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization

17/17

5.2 5.3 5.4 Chap. 5 review Conclusion References

References (1 of 1)

[1] Wikipedia Staff,Adventures of Huckleberry Finn (1885)/Chapter 5,https://en.wikisource.org/wiki/Adventures_of_

Huckleberry_Finn_(1885)/Chapter_5, 2016.

[2] Xilin Staff, Building applications in sdk, http://www.xilinx.com/support/documentation/sw_manuals/

xilinx12_2/SDK_Doc/concepts/sdk_c_build.htm, 2015.

[3] J. Stanley Warford, Computer Systems, Jones & BartlettPublishers, 2010.