CThe lowest high level language even lower than

  • Slides: 12
Download presentation
C-The lowest "high level" language. . . even lower than C.

C-The lowest "high level" language. . . even lower than C.

C-- Background q C-- was developed by Gill Bates at MIT as a term

C-- Background q C-- was developed by Gill Bates at MIT as a term project for a course on compilers. q The name "C--" is the grade he got in the course.

Description of C-q q C-- is designed to be even more "low level" than

Description of C-q q C-- is designed to be even more "low level" than C. It gives the programmer direct access to the stack, access to registers of the CPU, and very low level memory management.

Language Progression Java Progress C++ C# Objective C C with Classes C C+- ("C

Language Progression Java Progress C++ C# Objective C C with Classes C C+- ("C more or less") B C-- ("less than C") Algol C-- is "orthogonal" to all other languages. Time

Distinctive Characteristics q q A C-- program requires even more instructions than the same

Distinctive Characteristics q q A C-- program requires even more instructions than the same program written in assembly language. In this respect, C-- is similar to COBOL.

Design Goals were to give the programmer low-level control access to computer resources. q

Design Goals were to give the programmer low-level control access to computer resources. q programmer can change things he should not touch. q machine independence is not a goal. q security is not a goal q abstraction is not a goal -computer programs should look like computer programs

Characteristics Memory Management q Programmer must manage memory himself Type System Weak type checking

Characteristics Memory Management q Programmer must manage memory himself Type System Weak type checking … even weaker than C. q No automatic type promotion Pointers and Referencing q C pointers look easy in comparison to C— Weak Polymorphism q q C-- doesn’t verify arguments, so you can pass any values to a function. No function overloading. Everything is the Programmer’s Responsibility!

Run-Time Stack for Method Invocations Memory

Run-Time Stack for Method Invocations Memory

Sample C-- Program: compute a+b #include <registers. h> float sum( ) { // no

Sample C-- Program: compute a+b #include <registers. h> float sum( ) { // no formal parameters! // you must manage the stack pointer yourself static unsigned int sp = getstackpointer( ); a = (int) getstack(sp); // get the first parameter b = (float) getstack(sp+4); // get the second parameter float sum; // definition only, no storage &sum = stackalloc(sp+8); // allocate storage yourself! sum = (float)a + b; // no automatic type conversion putstack(sp + 8, sum); // put return value on the stack returnto getstack(sp – 4); // jump to return addr from stack }

Contribution to Computer Languages q No contributions that I could find. q All links

Contribution to Computer Languages q No contributions that I could find. q All links to "C--" on the WWW have been erased!

Useful Applications q Still used at MIT as punishment for student who cheat on

Useful Applications q Still used at MIT as punishment for student who cheat on projects. (Cheater must do senior project in C--)

Resources q http: //www. cs. mit. edu/compilers/c-- [obsolete[

Resources q http: //www. cs. mit. edu/compilers/c-- [obsolete[