Presentation is loading. Please wait.

Presentation is loading. Please wait.

12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt1 Topic 2b High-Level languages and System Software (Languages) Introduction to Computer Systems Engineering.

Similar presentations


Presentation on theme: "12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt1 Topic 2b High-Level languages and System Software (Languages) Introduction to Computer Systems Engineering."— Presentation transcript:

1 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt1 Topic 2b High-Level languages and System Software (Languages) Introduction to Computer Systems Engineering (CPEG 323)

2 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt2 Reading List Slides: Topic2b K & R : C Programming Language JAVA in a Nutshell

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 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt3

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

5 Timeline of Programming Languages 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt5 Courtesy of Wikipedia. Original Author: Maximilian Dörrbecker

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 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt6

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 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt7

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

9 C versus Java Hello, World in CHello, World in Java 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt9 #include 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!"); }

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

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 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt11

12 Memory Storage for HLPL Linear Storage of multi dimensional array Row Major order (C, C++, JAVA) 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt12 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) 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) Memory

13 Memory Storage for HLPL Column Major order (Fortran, MATLAB) 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt13 Memory 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) 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)

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) 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt14

15 Load 32-bit Immediate 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt15 LUI R9, 0xAAAA op16-bit Imm AAAA BBBB op 16-bit Imm R9 ADDIU R9, R9, 0xBBBB

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

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 12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt17


Download ppt "12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt1 Topic 2b High-Level languages and System Software (Languages) Introduction to Computer Systems Engineering."

Similar presentations


Ads by Google