CS270 Colorado State University =================== Subversion Overview =================== Concepts Repository % cd SVNRepositories // organizational convenience % svnadmin create Blah % pwd // Helps us figure out where to import to Initial directory for project Can be on any machine on the network. Putting at least one file in the initial directory makes things easier to understand, but is not required. % mkdir Blah.start % cd Blah.start % pico README Import this starting directory to the repository. % setenv SVN_SSH 'ssh -l cs270' % svn import . svn+ssh://dmx.cs.colostate.edu//s/bach/a/class/cs270/SVNRepositories/Blah -m "Initial import" Working directories Can be on any machine on the network. % cd % cd Temp % svn co svn+ssh://dmx.cs.colostate.edu//s/bach/a/class/cs270/SVNRepositories/Blah Blah % cd Blah % ls -al // notice the .svn directory. // Indicates we are in subversion working directory. What if we mess up README and then commit? % pico README % svn commit -m "Changed name in README" // Oops! % svn log README % svn cat -r 1 README // Revision 1 is printed to standard out. % svn cat -r 1 README > README // Make README be same as revision 1. % more README % svn commit -m "Reverting README to revision 1" % svn log README =========================== Number Representation in C =========================== Fantastic C Programming Tutorial on the Web. Read section (E Numbers). http://irc.essex.ac.uk/www.iota-six.co.uk/c/ Ch. 12.2 and 12.3 in book. --------------------------- Data types data type number of bits representation range ------------- -------------- -------------- ----- unsigned int int char boolean float How are the integers 30 and -75 represented with bits using 2's complement? No direct way to view binary representation in C program. Where there is a will, there is a way. ------------------------ Bit Shifting and Masking Enables us to get at individual bits and/or sets of bits. Shifting shift right logical 0 extension -- 0's shifted in from left shift right arithmetic sign extension -- sign bit duplicated shift left logical 0's shifted in from the right Masking Use bit operations and bit identities to extract desired bits. If want value of least significant bit, then do a logical AND with the number one. 0000 0000 0000 0000 0000 0000 0000 0001 & 1111 1111 1111 1111 1111 1111 1011 0101 (-75) --------------------------------------- Combine shifting with masking to discover bits in integer representation unsigned int num = 0x55555555; unsigned int mask = 0x80000000; MSB = mask & num; mask = mask >> 1; next_bit = mask & num; ------------------------------- Big endian versus little endian http://www.cs.umass.edu/~verts/cs32/endian.html http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Data/endian.html unsigned int a = 0x41424344; Big-Endian / Forward Byte Order / Network Order (MIPS, ARM, Sparc) - BYTES are stored from most significant to least. Little-Endian / Backward Byte Order (x86) - BYTES are stored from least significant to most. Using C to figure out endianness char *ptrChar = (char *) &a; for ( i = 0; i < sizeof( unsigned int ); ++i ) { printf( "%c", ptrChar ); } --------------------------- Convenience of Hexadecimal -Every 4 bits map to a single hex digit. -Frequently used to express memory addresses and memory in the context of low-level debugging. -For tests you will need to do this translation very quickly. ------------------------------------------------------------------------------- Questions you should be able to answer at the end of this unit - Using bit operations in C, how can you print bit X through bit Y from within a ZZ-bit word? ------------------------ mstrout@cs.colostate.edu, 9/2/08