Skip to content
Browse files

Following along in chapter 33.

  • Loading branch information...
1 parent 9684437 commit fe995e4e577ded91476016499d7a6b23b630250a Nick committed Sep 2, 2013
View
223 Chapter33/bitwize/bitwize.xcodeproj/project.pbxproj
@@ -0,0 +1,223 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 015D8CAA17D5819B00A05F81 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 015D8CA917D5819B00A05F81 /* main.c */; };
+ 015D8CAC17D5819B00A05F81 /* bitwize.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 015D8CAB17D5819B00A05F81 /* bitwize.1 */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ 015D8CA417D5819B00A05F81 /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = /usr/share/man/man1/;
+ dstSubfolderSpec = 0;
+ files = (
+ 015D8CAC17D5819B00A05F81 /* bitwize.1 in CopyFiles */,
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 015D8CA617D5819B00A05F81 /* bitwize */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = bitwize; sourceTree = BUILT_PRODUCTS_DIR; };
+ 015D8CA917D5819B00A05F81 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
+ 015D8CAB17D5819B00A05F81 /* bitwize.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = bitwize.1; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 015D8CA317D5819B00A05F81 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 015D8C9D17D5819B00A05F81 = {
+ isa = PBXGroup;
+ children = (
+ 015D8CA817D5819B00A05F81 /* bitwize */,
+ 015D8CA717D5819B00A05F81 /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ 015D8CA717D5819B00A05F81 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 015D8CA617D5819B00A05F81 /* bitwize */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 015D8CA817D5819B00A05F81 /* bitwize */ = {
+ isa = PBXGroup;
+ children = (
+ 015D8CA917D5819B00A05F81 /* main.c */,
+ 015D8CAB17D5819B00A05F81 /* bitwize.1 */,
+ );
+ path = bitwize;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 015D8CA517D5819B00A05F81 /* bitwize */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 015D8CAF17D5819B00A05F81 /* Build configuration list for PBXNativeTarget "bitwize" */;
+ buildPhases = (
+ 015D8CA217D5819B00A05F81 /* Sources */,
+ 015D8CA317D5819B00A05F81 /* Frameworks */,
+ 015D8CA417D5819B00A05F81 /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = bitwize;
+ productName = bitwize;
+ productReference = 015D8CA617D5819B00A05F81 /* bitwize */;
+ productType = "com.apple.product-type.tool";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 015D8C9E17D5819B00A05F81 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0460;
+ ORGANIZATIONNAME = "Nicholas Squire";
+ };
+ buildConfigurationList = 015D8CA117D5819B00A05F81 /* Build configuration list for PBXProject "bitwize" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 015D8C9D17D5819B00A05F81;
+ productRefGroup = 015D8CA717D5819B00A05F81 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 015D8CA517D5819B00A05F81 /* bitwize */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 015D8CA217D5819B00A05F81 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 015D8CAA17D5819B00A05F81 /* main.c in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 015D8CAD17D5819B00A05F81 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.8;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ 015D8CAE17D5819B00A05F81 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.8;
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
+ 015D8CB017D5819B00A05F81 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ 015D8CB117D5819B00A05F81 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 015D8CA117D5819B00A05F81 /* Build configuration list for PBXProject "bitwize" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 015D8CAD17D5819B00A05F81 /* Debug */,
+ 015D8CAE17D5819B00A05F81 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 015D8CAF17D5819B00A05F81 /* Build configuration list for PBXNativeTarget "bitwize" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 015D8CB017D5819B00A05F81 /* Debug */,
+ 015D8CB117D5819B00A05F81 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 015D8C9E17D5819B00A05F81 /* Project object */;
+}
View
79 Chapter33/bitwize/bitwize/bitwize.1
@@ -0,0 +1,79 @@
+.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
+.\"See Also:
+.\"man mdoc.samples for a complete listing of options
+.\"man mdoc for the short list of editing options
+.\"/usr/share/misc/mdoc.template
+.Dd 9/2/13 \" DATE
+.Dt bitwize 1 \" Program name and manual section number
+.Os Darwin
+.Sh NAME \" Section Header - required - don't modify
+.Nm bitwize,
+.\" The following lines are read in generating the apropos(man -k) database. Use only key
+.\" words here as the database is built based on the words here and in the .ND line.
+.Nm Other_name_for_same_program(),
+.Nm Yet another name for the same program.
+.\" Use .Nm macro to designate other names for the documented program.
+.Nd This line parsed for whatis database.
+.Sh SYNOPSIS \" Section Header - required - don't modify
+.Nm
+.Op Fl abcd \" [-abcd]
+.Op Fl a Ar path \" [-a path]
+.Op Ar file \" [file]
+.Op Ar \" [file ...]
+.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
+arg2 ... \" Arguments
+.Sh DESCRIPTION \" Section Header - required - don't modify
+Use the .Nm macro to refer to your program throughout the man page like such:
+.Nm
+Underlining is accomplished with the .Ar macro like this:
+.Ar underlined text .
+.Pp \" Inserts a space
+A list of items with descriptions:
+.Bl -tag -width -indent \" Begins a tagged list
+.It item a \" Each item preceded by .It macro
+Description of item a
+.It item b
+Description of item b
+.El \" Ends the list
+.Pp
+A list of flags and their descriptions:
+.Bl -tag -width -indent \" Differs from above in tag removed
+.It Fl a \"-a flag as a list item
+Description of -a flag
+.It Fl b
+Description of -b flag
+.El \" Ends the list
+.Pp
+.\" .Sh ENVIRONMENT \" May not be needed
+.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
+.\" .It Ev ENV_VAR_1
+.\" Description of ENV_VAR_1
+.\" .It Ev ENV_VAR_2
+.\" Description of ENV_VAR_2
+.\" .El
+.Sh FILES \" File used or created by the topic of the man page
+.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
+.It Pa /usr/share/file_name
+FILE_1 description
+.It Pa /Users/joeuser/Library/really_long_file_name
+FILE_2 description
+.El \" Ends the list
+.\" .Sh DIAGNOSTICS \" May not be needed
+.\" .Bl -diag
+.\" .It Diagnostic Tag
+.\" Diagnostic informtion here.
+.\" .It Diagnostic Tag
+.\" Diagnostic informtion here.
+.\" .El
+.Sh SEE ALSO
+.\" List links in ascending order by section, alphabetically within a section.
+.\" Please do not reference files that do not exist without filing a bug report
+.Xr a 1 ,
+.Xr b 1 ,
+.Xr c 1 ,
+.Xr a 2 ,
+.Xr b 2 ,
+.Xr a 3 ,
+.Xr b 3
+.\" .Sh BUGS \" Document known, unremedied bugs
+.\" .Sh HISTORY \" Document history if command behaves in a unique manner
View
47 Chapter33/bitwize/bitwize/main.c
@@ -0,0 +1,47 @@
+//
+// main.c
+// bitwize
+//
+// Created by Nicholas Squire on 9/2/13.
+// Copyright (c) 2013 Nicholas Squire. All rights reserved.
+//
+
+#include <stdio.h>
+
+int main(int argc, const char * argv[])
+{
+ unsigned char a = 0x3c;
+ unsigned char b = 0xa9;
+ unsigned char c = a | b;
+
+ printf("Hex: %x | %x = %x\n", a, b, c);
+ printf("Decimal: %d | %d = %d\n", a, b, c);
+
+ unsigned char d = a & b;
+
+ printf("Hex: %x & %x = %x\n", a, b, d);
+ printf("Decimal: %d & %d = %d\n", a, b, d);
+
+ unsigned char e = a ^ b;
+
+ printf("Hex: %x ^ %x = %x\n", a, b, e);
+ printf("Decimal: %d ^ %d = %d\n", a, b, e);
+
+ unsigned char f = ~b;
+
+ printf("Hex: the complement of %x is %x\n", b, f);
+ printf("Decimal: the complement of %d is %d\n", b, f);
+
+ unsigned char g = a << 2;
+
+ printf("Hex: %x shifted left two places is %x\n", a, g);
+ printf("Decimal: %d shifted left two places is %d\n", a, g);
+
+ unsigned char h = a >> 1;
+
+ printf("Hex: %x shifted right one place is %x\n", a, h);
+ printf("Decimal: %d shifted right one place is %d\n", a, h);
+
+ return 0;
+}
+

0 comments on commit fe995e4

Please sign in to comment.
Something went wrong with that request. Please try again.