Presentation is loading. Please wait.

Presentation is loading. Please wait.

March 2005 1R. Smith - University of St Thomas - Minnesota ENGR 330: Today’s Class More “Clarifications” ?More “Clarifications” ? Interrupts – integrating.

Similar presentations


Presentation on theme: "March 2005 1R. Smith - University of St Thomas - Minnesota ENGR 330: Today’s Class More “Clarifications” ?More “Clarifications” ? Interrupts – integrating."— Presentation transcript:

1 March 2005 1R. Smith - University of St Thomas - Minnesota ENGR 330: Today’s Class More “Clarifications” ?More “Clarifications” ? Interrupts – integrating hardware & softwareInterrupts – integrating hardware & software C – getting a compilerC – getting a compiler C – doing itC – doing it

2 March 2005 2R. Smith - University of St Thomas - Minnesota Interrupts The ‘ask a question’ analogyThe ‘ask a question’ analogy –Prioritizing First come first servedFirst come first served Favorites firstFavorites first Integrating hardware and softwareIntegrating hardware and software –What does the hardware do? –What does the software do?

3 March 2005 3R. Smith - University of St Thomas - Minnesota Examples Where do interrupts get involved?Where do interrupts get involved? Start “keyboard read”Start “keyboard read” Start “printer output”Start “printer output” Start “disk read”Start “disk read” Start “disk write”Start “disk write” Page interruptPage interrupt

4 March 2005 4R. Smith - University of St Thomas - Minnesota Programming Languages Compilers vs InterpretersCompilers vs Interpreters –Perl, Lisp, Basic are usually interpreters –C, Fortran, “classic” languages are compiled The 3 step processThe 3 step process –Code – compile – run C generates “machine code”C generates “machine code” –Java produces ‘machine independent bytecodes’ C is “just a little” above assembly languageC is “just a little” above assembly language –You get to play with RAM addresses

5 March 2005 5R. Smith - University of St Thomas - Minnesota The C Compiler PreprocessorPreprocessor –Handles operations with # in column 1 CompilerCompiler –Two phases build and use a symbol table, like assemblers –Phase 1 reads the code and analyzes its structure Finds syntax errorsFinds syntax errors –Phase 2 generates the actual executable code LinkerLinker –For ‘linking together’ binaries that were compiled separately –Combine a ‘main’ program with library procedures getchar(), putchar(), println()getchar(), putchar(), println()

6 March 2005 6R. Smith - University of St Thomas - Minnesota Getting a C Compiler They’re all “pretty” standardThey’re all “pretty” standard We are doing “standard I/O”We are doing “standard I/O” –No graphics, windows, ad nauseum If you have one, keep with itIf you have one, keep with it I’ll be using Watcom (University of Waterloo)I’ll be using Watcom (University of Waterloo) Monday’s Assignment: get a compiler and write ‘Hello World’ with it. Hand in a ‘reflection’ on it.Monday’s Assignment: get a compiler and write ‘Hello World’ with it. Hand in a ‘reflection’ on it.

7 March 2005 7R. Smith - University of St Thomas - Minnesota Using C We’ve all taken Java or something, right?We’ve all taken Java or something, right? C is Java without objectsC is Java without objects –Or, with address calculations substituted for objects –Some would say it’s a good trade Others would compare it with trading a safety razor for a straight razor (or a sharp knife)Others would compare it with trading a safety razor for a straight razor (or a sharp knife) The safety razor requires more “infrastructure”The safety razor requires more “infrastructure” the straight razor is more versatile and more dangerousthe straight razor is more versatile and more dangerous Hello World?Hello World?

8 March 2005 8R. Smith - University of St Thomas - Minnesota C weirdnesses Actual code starts with: int main() {Actual code starts with: int main() { –Like public static int main(String[] args) in java EVERYTHING Returns a ValueEVERYTHING Returns a Value –Assignment statements, many procedures, conditionals, etc. Avoid weird, stupid, and/or dangerous thingsAvoid weird, stupid, and/or dangerous things –Increment operators except in selected places –Using the result of an assignment statement –I won’t use the “assignment operators” Can’t avoid all such thingsCan’t avoid all such things –Address arithmetic is unavoidable

9 March 2005 9R. Smith - University of St Thomas - Minnesota I/O makes a program ‘interesting’ #include #include getchar() returns the next charactergetchar() returns the next character –Greater than zero is a character –Treat 0 as end of file –Look for ‘\n’ to find the end of a line putchar(ch) writes the character ‘ch’ to outputputchar(ch) writes the character ‘ch’ to output –Again, ‘\n’ starts a new line printf(“Text string\n”)printf(“Text string\n”) –Prints text strings –Can also do outbound number conversion

10 March 2005 10R. Smith - University of St Thomas - Minnesota Inbound Number Conversion A good exerciseA good exercise –Gets us thinking about the difference between numbers and their representations –We can generalize this to all bases Num = (Num * Base) + (NextChar – ‘0’)Num = (Num * Base) + (NextChar – ‘0’) Just loop till NextChar isn’t a digit.Just loop till NextChar isn’t a digit.

11 March 2005 11R. Smith - University of St Thomas - Minnesota That’s it. Questions?Questions? Creative Commons License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.


Download ppt "March 2005 1R. Smith - University of St Thomas - Minnesota ENGR 330: Today’s Class More “Clarifications” ?More “Clarifications” ? Interrupts – integrating."

Similar presentations


Ads by Google