User Tools

Site Tools


notes:sysprog:projects:wut2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:sysprog:projects:wut2 [2018/02/15 01:00] – [addition.c - Kris] kbeykircnotes:sysprog:projects:wut2 [2018/02/15 15:31] (current) – [rotate.c - Aaron Houghtaling] ahought2
Line 9: Line 9:
 =====endian.c===== =====endian.c=====
 =====checksum.c===== =====checksum.c=====
-=====twoscomp.c=====+=====twoscomp.c (bschulte)===== 
 + 
 +Last week, I had a broken, messy version of twoscomp.c. So I decided to rewrite it for wut2. Everything works except for only one string can be input at a time.  
 + 
 +<code> 
 +./twoscomp -s "10010110" 
 +01101010 
 + 
 +./twoscomp -v -s "10010110" 
 +Verbose mode on: probably less ugly 
 + 
 +Base:             2 
 +Wordsize:         8 
 + 
 +10010110 -> 01101001 + 1 = 01101010 
 + 
 +./twoscomp -w 4 -s "1001" 
 +0111 
 + 
 +./twoscomp -w 4 -v -s "1001" 
 +Verbose mode on: probably less ugly 
 + 
 +Base:             2 
 +Wordsize:         4 
 + 
 +1001 -> 0110 + 1 = 0111 
 + 
 + ./twoscomp -s "100100" 
 +Improper String Length. Wordsize is: 8 
 +String is: 6 characters long 
 + 
 +./twoscomp -b 10 -s "10" 
 +10 -> 246 
 + 
 +./twoscomp -v -b 10 -s "10" 
 +Verbose mode on: probably less ugly 
 + 
 +Base:             10 
 +Wordsize:         8 
 + 
 +10 -> 00001010 -> 11110101 + 1 = 11110110 -> 246 
 + 
 +./twoscomp -v -w 4 -b 10 -s "10" 
 +Verbose mode on: probably less ugly 
 + 
 +Base:             10 
 +Wordsize:         4 
 + 
 +10 -> 1010 -> 0101 + 1 = 0110 -> 6 
 + 
 +./twoscomp  -b 10 -s "124" 
 +124 -> 132 
 + 
 +./twoscomp  -w 32 -b 10 -s "124" 
 +4294967172 
 + 
 +./twoscomp  -v -w 32 -b 10 -s "124" 
 +Verbose mode on: probably less ugly 
 + 
 +Base:             10 
 +Wordsize:         32 
 + 
 +124 -> 00000000000000000000000001111100 ->  
 +11111111111111111111111110000011 + 1 =  
 +11111111111111111111111110000100 -> 
 +4294967172 
 + 
 +./twoscomp  -v -w 8 -b 10 -s "255" 
 +Verbose mode on: probably less ugly 
 + 
 +Base:             10 
 +Wordsize:         8 
 + 
 +255 -> 11111111 -> 00000000 + 1 = 00000001 -> 1 
 + 
 +./twoscomp  -w 8 -b 10 -s "256" 
 + 
 +Segmentation fault 
 + 
 +./twoscomp   -v -w 32 -b 10 -s "6553" 
 +Verbose mode on: probably less ugly 
 + 
 +Base:             10 
 +Wordsize:         32 
 + 
 +6553 -> 00000000000000000001100110011001 ->  
 +11111111111111111110011001100110 + 1 =  
 +11111111111111111110011001100111 -> 
 +4294960743 
 + 
 +./twoscomp   -b 8 -s "123" 
 +123 -> 83 -> 193 -> 301 
 + 
 +./twoscomp  -v  -b 8 -s "123" 
 +Verbose mode on: probably less ugly 
 + 
 +Base:             8 
 +Wordsize:         8 
 + 
 +123 -> 83 -> 01010011 -> 10101100 + 1 = 10101101 -> 173 -> 255 
 + 
 +/twoscomp  -b 16 -s "af" 
 +1015 -> 175 -> 81 -> 51  //a = 10 f = 15, hence 1015 -> 175 
 + 
 +/twoscomp  -v -b 16 -s "af" 
 +Verbose mode on: probably less ugly 
 + 
 +Base:             16 
 +Wordsize:         8 
 + 
 +1015 -> 175 -> 10101111 -> 01010000 + 1 = 01010001 -> 81 -> 51 
 + 
 +./twoscomp --help 
 +~~~~~twoscomp.c help page~~~~~ 
 + 
 +Usage: ./twoscomp -s [STRING] [OPTION] 
 + 
 + -q, --quiet 
 +        suppress all output 
 + -V, --version 
 +        print version info 
 + -v, --verbose 
 +        includes printout of all values specified by options 
 + -D, --debug 
 +       prints all debug statements. Probably pretty ugly 
 + -s [STRING], --string[=STRING] 
 +        The string to be processed. 
 + -d [DELIM], --delim[=DELIM] 
 +        Changes delimeter to [DELIM]. Defaults to space 
 + -w [SIZE], --wordsize[=SIZE] 
 +        Sets the wordsize to [SIZE}. Defaults to 8 
 +        Must be power of 2, between 4 and 128 
 + -b [BASE], --BASE[=BASE] 
 +        Changes the input/output base. Defaults to base 2 
 + 
 +./twoscomp -V 
 +twoscomp Ver. 0.2 
 + 
 +//I also included my own -D debugging option 
 + 
 +./twoscomp -D -s "10010110" 
 +Debug mode on~~: this is gonna be ugly 
 +Verbose mode on: probably less ugly 
 +==================~~~~=============== 
 + 
 +Size of Binary[]: 9 
 +Base:             2 
 +Wordsize:         8 
 +Copied Input:     10010110 
 +Size of Binary[]: 9 
 +Start of toBinary() 
 +Base is 2 
 +After toBinary(), binary[] is: 10010110 
 +Start of twoscomp() 
 +10010110 -> 01101001 + 1 =  
 +After twoscomp(), binary[] is: 01101010 
 +end of twoscomp() 
 +Start of toDec() 
 + 
 +End of toDec 
 +After toDec, convDec is: 0 
 +After toDec(), binary[] is(should be unchanged): 01101010 
 +End of toBinary/printnum() call 
 +Start of printnum() 
 +01101010 
 +End of printnum 
 +</code>
 =====addition.c - Kris===== =====addition.c - Kris=====
  
Line 158: Line 324:
  
  
-=====rotate.c=====+=====rotate.c - Aaron Houghtaling===== 
 + 
 +rotate.c is a program that when given a set of bits will shift them left or right and carry over the removed bit and tacked onto the left or right side respectively. 
 + 
 +Some Examples: 
 +<cli> 
 +lab46:~/src/sysprog/wut2/src$ ./rotate 1101 
 +1110 
 + 
 +lab46:~/src/sysprog/wut2/src$ ./rotate -s "1101" 
 +1110 
 + 
 +lab46:~/src/sysprog/wut2/src$ ./rotate -R 3 -s "1101" 
 +1011 
 + 
 +lab46:~/src/sysprog/wut2/src$ ./rotate -L 3 -s "1101" 
 +1110 
 + 
 +lab46:~/src/sysprog/wut2/src$ ./rotate -V 
 +Version: rotate 2.0 
 + 
 +lab46:~/src/sysprog/wut2/src$ ./rotate -R 9 -s "1101" 
 +1110 
 + 
 +lab46:~/src/sysprog/wut2/src$ ./rotate -d , -s "1101,101" 
 +1110 
 +110 
 + 
 +lab46:~/src/sysprog/wut2/src$ ./rotate -d , -S -s "1101,101" 
 +1110 110 
 + 
 +lab46:~/src/sysprog/wut2/src$ ./rotate -4 -s "11100" 
 +Error: input does not match byte size! 
 + 
 +lab46:~/src/sysprog/wut2/src$ ./rotate -h 
 +Usage: rotate [OPTION]... 
 +Rotates bits from a given input based on args given 
 +Rotates default behavior without arguments is to shift right by one bit 
 + 
 +Optional Arguments: 
 +   -h              display this help information and exit 
 +   -V              display rotate.c version information and exit 
 +   -S              display output on a SINGLE line. 
 +                   Default is to print on a new line with each value 
 + 
 +   -s [STRING]     specify "STRING" as value 
 +                   Default accepts SPACE seperated values 
 +                   ex: -s "1011 1110" 
 + 
 +   -4              set nibble as processing unit size 
 +   -7              set byte size to 7-bits 
 +   -8              set byte size to 8-bits 
 +   -n              no delimiter between units. Can only contain ONE value 
 +                   ex: 1011 1110 will process as only 1011 
 + 
 +   -d [CHAR]       use "CHAR" as delimiter between units 
 +   -q              quiet all STDOUT output 
 +   -v              display MORE information to STDOUT 
 +   -w [#]          set "#" as byte size (4-128) 
 +   -L [#]          rotate LEFT  by "#" of bytes 
 +   -R [#]          rotate RIGHT by "#" of bytes 
 + 
 +For further information contact: ahought2@corning-cc.edu 
 +</cli>
 =====invert.c===== =====invert.c=====
 +A bit-wise inversion is an operation where the end outputs the opposite bit of the beginning input. What this means is that the input bit of 1 will result in a 0 after this operation.  
 +Example of outputs and error messages:
 +<code>
 +./invert -s "10011010 11010001" -->  01100101 00101110
 +</code>
 +<code>
 +echo "1100101100011101" | ./invert --> 0011010011100010
 +</code>
 +<code>
 +echo "1000100" | ./invert -B --> 0111011
 +</code>
 +<code>
 +echo "12" | ./invert -B --> invalid number!
 +</code>
 +<code>
 +./invert -V --> 0.0.2
 +</code>
 +<code>
 +./invert --help
 +Usage: ./invert [OPTION]... [FILE]...
 +performs a bit inversion against a set of input values!
  
 +Arguments:
 + -h, --help             display usage information
 + -V, --Version          display version information
 + -s,  -string           specify STRING as value to process
 + -v,  -verbose          displays more information to STDOUT
 + -d,  -delimiter        use the argument as a delimiter
 + -q,  -quiet            do not display anything to STDOUT
 + -B,  -Binary           input data is to be considered as binary
 + -O,  -Octal            input data is to be considered as octal
 + -D,  -Decimal          input data is to be considered as decimal
 + -H,  -Hexadecimal      input data is to be considered as hexadecimal
 +</code>
notes/sysprog/projects/wut2.1518656448.txt.gz · Last modified: 2018/02/15 01:00 by kbeykirc