CPSC 233 Tutorial

of 12 /12
CPSC 233 Tutorial Xin Liu 2011/01/17

Embed Size (px)

description

CPSC 233 Tutorial. Xin Liu 2011/01/17. Self-intro. Xin Liu PhD student Email: [email protected] Homepage: http://pages.cpsc.ucalgary.ca/~liuxin CT: Thursday 12:00-2:00 @ CT desk. Unix Environment. Working in the lab is suggested Remote access using SSH On Windows: - PowerPoint PPT Presentation

Transcript of CPSC 233 Tutorial

Slide 1

CPSC 233 TutorialXin Liu2011/01/17Self-introXin LiuPhD studentEmail: [email protected]: http://pages.cpsc.ucalgary.ca/~liuxinCT: Thursday 12:00-2:00 @ CT deskUnix EnvironmentWorking in the lab is suggestedRemote access using SSHOn Windows: Download SSH Client program from http://www.ucalgary.ca/it/software/sshQuick ConnectHost Name: csc.cpsc.ucalgary.caUser Name: xxxOn Mac:using terminal to connect to the UNIX systemssh @csc.cpsc.ucalgary.ca

AssignmentSubmit your Assignments with submit command of UNIXSubmitsubmit -c -a eg. submit -c 233 -a 3 a3.p READMEList submitted filesshowstuff -c -a eg. showstuff -c 233 -a 3Submit early and updateAvoid plagiarismMOSS ( Measure of Software Similarity )http://theory.stanford.edu/~aiken/moss/Cite if necessaryNo marks lost by citing example code from TA/instructorBinary NumbershexadecimalBinaryhexadecimalBinary0x000000x810000x100010x910010x200100xA / 1010100x300110xB / 1110110x401000xC / 1211000x501010xD / 1311010x601100xE / 1411100x701110xF / 151111Byte: 8 bitsWord: 16 bitsDouble word: 32 bitsQuad word: 64 bitsMultiples of 4 bits, corresponding to a hexadecimal numberBin Dec101011.01011*25 + 0*24 + 1*23 + 0*22 + 1*21 + 1*20 + 0*2-1 + 1*2-2 + 0*2-3 + 1*2-4 = 32 + 0 + 8 + 0 + 2 + 1 + 0 + 0.25 + 0 + 0.0625 = 43.3125

Other examples Dec BinConvert Integer and Decimal parts seperatelyExample: 37.43 100101.01101b

Negative IntegersThree representationsRegular binary (true code)0110 0100 (DEC 100)1110 0100 (DEC -100)Ones complement (flip each bit)0110 0100 (DEC 100)1001 1011 (DEC -100)Twos complement (flip each bit + 1) most useful!!!0110 0100 (DEC 100)1001 1100 (DEC -100)Negative integersTwos complementDefinition: 2N-x for an N-bit numberRegular binary twos complement:Positive: No changeNegative: flip bitwise + 1

Dec: - 95 10100001-----------------------------95: - 0101 1111true code1010 0000Flip (ones complement)1010 0001+1the value obtained by subtracting the number from a large power of two9Integer AdditionDirectly add the numbers, no matter positive or negativeCheck left two carry bit00 or 11 valid01 or 10 invalid (overflow) 11111 111 (carry) 0000 1111 (15)+ 1111 1011 (-5)================== 0000 1010 (10) 0111 (carry) invalid! 0111 (7)+ 0011 (3)============= 1010 (6)Integer Subtractionx - y = x + twos complement of yProcedures:Compute the twos complement of y (flip bits + 1)AdditionCheck for overflow

01100100 (x, equals decimal 100) - 00010110 (y, equals decimal 22)========== 11100000 (carry) valid! 01100100 (x) + 11101010 (twos complement of y)========== 101001110 (twos complement of result) 01001110 (regular binary of result 78)Integer SubtractionAnother example 01100100 (x, equals decimal 100) --11001000 (y, equals decimal -200)========== 01100000 (carry) invalid! 01100100 (x) + 00111000 (twos complement of y)========== 010011100 (twos complement of result) - 01100100 (regular binary of result -196)