1 / 13

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

This presentation provides an introduction to computer systems engineering and compares the features of the C and Java programming languages. It covers topics such as data abstraction, memory management, syntax differences, and array storage support.

Download Presentation

Topic 2c 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 2cHigh-Level languages and System Software(Languages) Introduction to Computer Systems Engineering (CPEG 323) \course\cpeg323-05Fs\Topic2c-323.ppt

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

  3. C and Java C • No built-in object abstraction. Data separate from methods. • “Functions” • Libraries are lower-level • Manualmemory management • Pointers Java • Object-oriented(OOP) • “Methods” • Class libraries of data structures • Automatic memory management \course\cpeg323-05Fs\Topic2c-323.ppt

  4. C and Java (cont.) Java • High memory overhead from class libraries • Relatively Slow • Arrays initialize to zero • Syntax:/* comment */// commentSystem.out.print C • Low memory overhead • Relatively Fast • Arrays initialize to garbage • Syntax:/* comment */printf \course\cpeg323-05Fs\Topic2c-323.ppt

  5. C and Java (cont.) • C compilers take C and convert it into an architecture specific machine code (string of 1s and 0s). • Unlike Java which converts to architecture independent bytecode. Java bytecode JVM JVM – Java Virtual Machine Hardware \course\cpeg323-05Fs\Topic2c-323.ppt

  6. Java Programming Environment Java Platform (http://www.artima.com/insidejvm/ed2/introarchP.html) \course\cpeg323-05Fs\Topic2c-323.ppt

  7. C Syntax • Very similar to Java, but with a few minor but important differences • All variable declarations must go before they are used (at the beginning of the block). • A variable may be initialized in its declaration. • Examples of declarations: • correct: { int a = 0, b = 10; ... • incorrect:for (int i = 0; i < 10; i++) \course\cpeg323-05Fs\Topic2c-323.ppt

  8. Array Storage Support • 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-05Fs\Topic2c-323.ppt

  9. Array Storage Support(Cont.) • column-major order (Fortran, MATLAB,…) Memory 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-05Fs\Topic2c-323.ppt

  10. Assembly Language • Compiler – generate assembly code • Assembly language: • Pseudo-instructions: not real hardware instructions, but help to be understand • li Rx, Imm - load immediate to register. Real instruction ? addiu Rx, R0, Imm (if Imm is less or equal than 16 bits) lui/ori pair (if Imm is more than 16bits) • la Rx, Var - load address of “var” into register. Real instruction? Two potential translations, depending on which data area “var” will be. addi Rx, GP, Offset In global data area, one instruction is needed. In other data area, two instructions are needed. lui Rx, HI16(var) addiu Rx, Rx, LOW16(var) \course\cpeg323-05Fs\Topic2c-323.ppt

  11. 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-05Fs\Topic2c-323.ppt

  12. 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-05Fs\Topic2c-323.ppt

  13. 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-05Fs\Topic2c-323.ppt

More Related