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 instructions andassemblers
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
7 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 20177 Nov. 2017
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
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.
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??
5/17
5.2 5.3 5.4 Chap. 5 review Conclusion References
Irritating things about direct addressing
Terrific quote
“In all these examples, theinstruction simply grinds through thevon Neumann execution cycle. Youmust always remember that thetranslation process is different fromthe execution process and thattranslation happens before execution.After translation, when theinstructions are executing, the originof the bits is irrelevant. The onlything that matters is what the bitsare, not where they came fromduring the translation phase.”
J. Stanley Warford [3]
J. Stanley Warford
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.
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.
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].
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].
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??
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.
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
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.
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.
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].
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
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.