1 / 17

Topic 2b High-Level languages and System Software (Languages)

Topic 2b High-Level languages and System Software (Languages). Introduction to Computer Systems Engineering (CPEG 323). Reading List. Slides: Topic 2 b K & R : C Programming Language JAVA in a Nutshell. Processors. Programs  Written in High Level Languages

fionan
Download Presentation

Topic 2b High-Level languages and System Software (Languages)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Topic 2bHigh-Level languages and System Software(Languages) Introduction to Computer Systems Engineering (CPEG 323) \course\cpeg323-07Fs\Topic2b-323.ppt

  2. Reading List • Slides: Topic2b • K & R : C Programming Language • JAVA in a Nutshell \course\cpeg323-07Fs\Topic2b-323.ppt

  3. Processors • Programs  Written in High Level Languages • How Processors see the high level languages? • The role of toolchains • Connections between ISA and high-level languages • Connections between ISA and Operating Systems \course\cpeg323-07Fs\Topic2b-323.ppt

  4. High Programming Languages • Portability • Abstraction • Penalty • Languages Categories • Imperative (C) • Functional (LISP) • Logic (PROLOG) • Object Oriented (Java) • Scripting (Python) \course\cpeg323-07Fs\Topic2b-323.ppt

  5. Timeline of Programming Languages Courtesy of Wikipedia. Original Author: Maximilian Dörrbecker \course\cpeg323-07Fs\Topic2b-323.ppt

  6. C versus Java • C • K&R • Initial implementation of C • 1978 • Weakly type checking for arguments and implicit integer return type. • ANSI C / ISO C (C89 and C90) • De facto standard • Function prototypes, void pointers, international character sets, preprocessor enhancements (e.g. ## concatenation), prototypes, etc \course\cpeg323-07Fs\Topic2b-323.ppt

  7. C versus Java • C • C99 • Extension to several compilers • Inline functions, new data types, variable length arrays (included in the GCC compiler), variadic macros, etc • Java • “Get the power and flexibility of C++, but in a smaller, simpler and safer language” • Not implicit pointers • Implicit Garbage Collection • Control statements  Only controlled by primitive booleans • Encapsulation is strictly enforced • Concurrency Control • Widening Cohercion only • Applet versus standalone versus servlet versus Javaserver page versus swing applications \course\cpeg323-07Fs\Topic2b-323.ppt

  8. C versus Java C Java Object Oriented Methods Class libraries of data structures Automatic Memory Management High Memory Overhead Relatively Slow Variables initialized to zero • Imperative • Functions • Libraries are low level • Manual Memory Management • Pointers • Low Memory Overhead • Relatively Fast • Variables initialize to garbage \course\cpeg323-07Fs\Topic2b-323.ppt

  9. C versus Java Hello, World in C Hello, World in Java #include <stdio.h> int main(int argc, char **argv) { /* This is a comment!!! */ printf("Hello, world!\n"); return 0; } public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } } \course\cpeg323-07Fs\Topic2b-323.ppt

  10. C versus Java Java Code C Code Lexical Analyzer Lexical Analyzer Syntax Analyzer Syntax Analyzer IR CG and Semantic Analyzer IR CG and Semantic Analyzer Symbol Table Optimizer Java Byte Code (e.g. Java Source code .class files) CG Java Virtual Machine Machine Code Java Platform Computer API Class files \course\cpeg323-07Fs\Topic2b-323.ppt

  11. C Syntax • Very similar to Java but with a few differences • Variable Declarations must go at the beginning of the block (before they are used) • A variable may be initialized in its declaration \course\cpeg323-07Fs\Topic2b-323.ppt

  12. Memory Storage for HLPL • Linear Storage of multi dimensional array • Row Major order (C, C++, JAVA) Memory A(1,1) A(1,2) A(1,3) A(1,4) A(1,5) A(2,1) A(2,2) A(2,3) A(2,4) A(2,5) A(3,1) A(3,2) A(3,3) A(3,4) A(3,5) A(4,1) A(4,2) A(4,3) A(4,4) A(4,5) int A[4][5] | int[][] A = new int[4][5]; A(1,1) A(1,2) A(1,3) A(1,4) A(1,5) A(2,1) A(2,2) A(2,3) A(2,4) A(2,5) A(3,1) A(3,2) A(3,3) A(3,4) A(3,5) A(4,1) A(4,2) A(4,3) A(4,4) A(4,5) \course\cpeg323-07Fs\Topic2b-323.ppt

  13. Memory Storage for HLPL Memory • Column Major order (Fortran, MATLAB) A(1,1) A(2,1) A(3,1) A(4,1) A(1,2) A(2,2) A(3,2) A(4,2) A(1,3) A(2,3) A(3,3) A(4,3) A(1,4) A(2,4) A(3,4) A(4,4) A(1,5) A(2,5) A(3,5) A(4,5) REAL A(4,5) A(1,1) A(1,2) A(1,3) A(1,4) A(1,5) A(2,1) A(2,2) A(2,3) A(2,4) A(2,5) A(3,1) A(3,2) A(3,3) A(3,4) A(3,5) A(4,1) A(4,2) A(4,3) A(4,4) A(4,5) \course\cpeg323-07Fs\Topic2b-323.ppt

  14. Assembly Language • Compiler  Generates Assembly code • Assembly language • Pseudo Instructions • li RX, Imm  Load Immediate to register • Translates to a pair of instructions (addiu / lui or addiu / shori) if the immediate is greater than 16 bits • la RX, VAR  Load address of “VAR” into register • Translates according to the area in which VAR resides • Global Area: one instruction  addi RX, GP, OFFSET • Another Area: Two Instructions  lui RX, HI16(VAR); addiu RX, RX, LOW16(VAR) \course\cpeg323-07Fs\Topic2b-323.ppt

  15. Load 32-bit Immediate ADDIU R9,R9, 0xBBBB LUI R9, 0xAAAA op 16-bit Imm R9 op 16-bit Imm R9 R9 R9 AAAA BBBB \course\cpeg323-07Fs\Topic2b-323.ppt

  16. Load 32-bit Immediate ADDI R9, R0, 0xAAAA op 16-bit Imm R9 R9 AAAA SHORI R9,R9, 0xBBBB op 16-bit Imm R9 R9 or Shift 16 bits AAAA BBBB \course\cpeg323-07Fs\Topic2b-323.ppt

  17. Assembly Language • Assembly language(cont.) • Assembler directives • .file – source file name • .text – start a text section • .align – alignment requirement • .data – data section • .rdata – read-only data section • .globl – an external name • .ent – entry of a function • .frame – information about the function frame • .mask – integer registers used in this function • .fmask – floating point registers used in this function • .ascii – define a string of characters \course\cpeg323-07Fs\Topic2b-323.ppt

More Related