Skip to content

Commit

Permalink
update lab1 to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
syqian committed Jan 18, 2017
1 parent 255128c commit f3c7779
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 9 deletions.
7 changes: 2 additions & 5 deletions L1-Data-Lab/bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ You are expressly forbidden to:
int bitAnd(int x, int y) {
return ~(~x | ~y);
}


/*
* getByte - Extract byte n from word x
* Bytes numbered from 0 (LSB) to 3 (MSB)
Expand All @@ -152,14 +150,13 @@ int bitAnd(int x, int y) {
* Rating: 2
*/
int getByte(int x, int n) {
int l = (n ^ 0x0011) << 1;
return x << l >> l;
return (x >> (n << 3)) & 0xFF;
}
/*
* logicalShift - shift x to the right by n, using a logical shift
* Can assume that 0 <= n <= 31
* Examples: logicalShift(0x87654321,4) = 0x08765432
* Legal ops: ~ & ^ | + << >>
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 20
* Rating: 3
*/
Expand Down
2 changes: 0 additions & 2 deletions L1-Data-Lab/bits.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@



int bitAnd(int, int);
int test_bitAnd(int, int);
int getByte(int, int);
Expand Down
2 changes: 0 additions & 2 deletions L1-Data-Lab/decl.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ test_rec test_set[] = {





{"bitAnd", (funct_t) bitAnd, (funct_t) test_bitAnd, 2, "| ~", 8, 1,
{{TMin, TMax},{TMin,TMax},{TMin,TMax}}},
{"getByte", (funct_t) getByte, (funct_t) test_getByte, 2,
Expand Down
Binary file modified L1-Data-Lab/dlc
Binary file not shown.
Binary file modified Lab-Materials/datalab.pdf
Binary file not shown.

0 comments on commit f3c7779

Please sign in to comment.