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 7 Nov. 2017 1/17
Table of contents (1 of 1) 1 5.2 Irritating things about direct addressing 2 5.3 How symbols make life easier. 3 5.4 Translating from Level HOL6 4 Chap. 5 review Assembly language 5 Conclusion 6 References 2/17
Irritating things about direct addressing A simple program. You (the human) have to know the code (hex) for everything. 3/17
Irritating things about direct addressing When do you stop printing a string? What is difference between C++ string and char[] when printing?? 4/17
Irritating things about direct addressing Terrific quote In all these examples, the instruction simply grinds through the von Neumann execution cycle. You must always remember that the translation process is different from the execution process and that translation happens before execution. After translation, when the instructions are executing, the origin of the bits is irrelevant. The only thing that matters is what the bits are, not where they came from during the translation phase. J. Stanley Warford [3] J. Stanley Warford 5/17
How symbols make life easier. Let the software worry about where things are. 6/17
How symbols make life easier. A truly silly program. The symbol this points to memory location 0000 Memory location 0000 contains the opcode for DEC0 with OprnSpec this and to treat the contents as decimal von Neumann starts at address 0000 Loads the instruction Executes the instruction (outputs the contents at memory location 0000) Stops The opcode is interpreted as data (as per the opcode) and output. Seems silly, but von Neumann doesn t distinguish between program and data. Powerful stuff. 7/17
Translating from Level HOL6 We ve bumped into the idea of compilers (née, translators) before. Compilers convert HOL directly into machine code (ones and zeros), or Compiler convert HOL in assembler level code that another program has to translate into machine code. A compiler is a program (albeit, a complex one). Image from [3]. 8/17
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 ELF file Executable and Linkable Format (ELF) tells computer where to get information and where to put it memory 9/17
Translating from Level HOL6 Some HOL statements get translated Statements that actually do something get translated: The cout statement The return statement return inside the main() becomes STOP only in the Pep/8 compiler. What about the other statements?? 10/17
Translating from Level HOL6 Some HOL statements don t get translated The #include <> is a compiler directive on where to get additional information The using namespace... is to make typing easier for the human The semicolons terminate a logical line All HOLs have the same types of problems: scoping, brevity, line endings, line beginings, etc. 11/17
Translating from Level HOL6 Variables are just named places in memory About variables: At the ISA level, they live in memory At the ASL level, they are labels for memory location At the HOL level, they exist There are generally three types of variables: Global available to everyone and remember things Local available to the current context and then lost Static available to the current context and then remembered Other available to lower context and then lost 12/17
Translating from Level HOL6 How to resolve structures and classes? Remember at the lowest level, there are only addresses. typedef takes a known type and makes a new type enum creates an int, limits the values it can assume, and gives those values names struct names a collection of contiguous memory locations We can now create an array of contiguous memory locations of the same type. The compiler keeps track of variable names, types, and locations in memory. A class is a block of contiguous memory locations that has addresses of functions inside of it. 13/17
Translating from Level HOL6 A special type of variable that doesn t vary. C++ uses the compiler directive const to tell the compiler to cause an error when the constant thing is modified. Pep/8 uses the.equate directive Usually you ll use immutable variables for safety and documentation purposes. 14/17
Assembly language Moving up the food chain. Relationship between assembly and machine code, Pages 194 and 195, Pep/8 pseudo operators, Immediate addressing and trap instructions, Concept of symbols, von Neumann, von Neumann, von Neumann, Translating from HOL6 Image from [1]. 15/17
5.2 5.3 5.4 Chap. 5 review Conclusion References What have we covered? Immediate addressing and the trap instructions Symbols Translating from level HOL6 Chapter review Next period: Test, Section 6.1, Assemblers and high order languages 16/17
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 & Bartlett Publishers, 2010. 17/17