CS 160 Lecture 5 Martin van Bommel Character
CS 160 Lecture 5 Martin van Bommel
Character Representation • • 1 byte = 8 bits = 1 character? 256 possible codes with 8 bits Assign a character to each code Two common assignments – ASCII - American Standard Code for Information Interchange – EBCDIC - Extended Binary Coded Decimal Interchange Code
ASCII Code Value 0 1 - 31 10 32 33 -47, 58 -64, 91 -96 48 - 57 65 - 90 97 - 122 Letter Null character Special Characters n = New line Space Punctuation 0 -9 A-Z a-z
16 bits? • • • Two characters? One integer? Part of a floating point? Machine language instruction? Memory address? • Depends on application!
Operating System • Program that acts as interface to other software and the underlying hardware Operating System Utility Programs Hardware Utilities Compilers Assemblers Editors E-mail
HLL to Machine Language • Enter HLL program into file using editor – program. c - source file • Translate source code to machine code – program. o - object file • Combine object code with libraries – program. exe - executable file • See Fig. 1 -12
IDE • Integrated Development Environment – combines editor, compiler, linker, loader – usually includes tools to assist in debugging • Note – IDE’s usually do not write to disk automatically – must remember to save work to disk often, especially before executing a program
Programming Errors • Vocabulary and grammar - syntax • Rules determine if statement legally constructed - syntax rules • Compiler checks rules - gives syntax errors • Programs also contain errors in logic - bugs • Debugging - finding & fixing logic errors • e. g. Lunar probe at 47. 5 degrees
Initial Program #include <stdio. h> void main(void) function { printf(“Hello, world. n”); } - library inclusion “main” - function “printf” to display string
- Slides: 9