Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Good Books to learn low-level C

Reply
Thread Tools

Good Books to learn low-level C

 
 
Ramzy Darwish
Guest
Posts: n/a
 
      04-07-2005
Hello,
I have a Bachelors in CS and a Masters in Comp. Graphics. In all of my
schoolwork, I used C and C++ and thought that I had a pretty good
understanding of the language(s). But now, as I really am trying to find
work as a C/C++ programmer, I am having trouble on programming interview
tests when they start asking about low-level C stuff dealing with memory and
binary numbers. Recently, I took a test for a SE position at Intel, which I
of course was very excited about, but I am pretty sure I bombed the test as
I didn't really know a lot of what they were asking and staying up all night
scouring the internet did not produce satisfying results (i.e. I didn't get
the job). I was able to come up with answers, but I don't think they were
correct as they will not respond to me (not even to say I failed).

What I want to know is how all of you out there learned the tricks that I
see you propose to questions dealing with C on a binary number level, or
actually using facts about the memory address of some data stored in memory.

I just ordered "Computer Systems: A Programmer's Perspective" and
"Illustrating C".
Of course I have K&R and Stroustrup, but they don't really go into this type
of stuff in detail (and I didn't expect them to).

Do you just have to learn it along the way like a lot of the PERL tricks?
Are there any books that teach you this stuff? Websites? Any help is
appreciated.

Thanks,
ramzy



 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      04-07-2005
"Ramzy Darwish" <(E-Mail Removed)> wrote in message
news:Y3%4e.23099$(E-Mail Removed)...
> Hello,
> I have a Bachelors in CS and a Masters in Comp. Graphics.

[...]
> I am having trouble

[...]
> with memory and binary numbers.


This I find beyond incredible. What instutition
issued you those degrees?


This isn't a question or issue about C anyway,
so it's not topical here. BTW google will find
you plenty of tutorials on number-bases, e.g.
binary. You might also want to peruse www.drmath.com

-Mike


 
Reply With Quote
 
 
 
 
Ramzy Darwish
Guest
Posts: n/a
 
      04-07-2005
Maybe I didn't explain myself very well. I understand binary numbers and how
to work with them, and I know how to work with memory in terms of allocating
and deallocating and taking care of memory leaks and all of that. What I was
referring to were the tricks I see people play with using bit patterns to
determine mathematical properties of numbers (i.e. 1 then all 0's equal
power of two, etc.).

I know all about bases and took my architecture courses. I was just looking
for a book that maybe helped one to try to look at a lower level than say
objects or structs or something similar.


"Mike Wahler" <(E-Mail Removed)> wrote in message
news:2m15e.2010$(E-Mail Removed) nk.net...
> "Ramzy Darwish" <(E-Mail Removed)> wrote in message
> news:Y3%4e.23099$(E-Mail Removed)...
>> Hello,
>> I have a Bachelors in CS and a Masters in Comp. Graphics.

> [...]
>> I am having trouble

> [...]
>> with memory and binary numbers.

>
> This I find beyond incredible. What instutition
> issued you those degrees?
>
>
> This isn't a question or issue about C anyway,
> so it's not topical here. BTW google will find
> you plenty of tutorials on number-bases, e.g.
> binary. You might also want to peruse www.drmath.com
>
> -Mike
>
>




 
Reply With Quote
 
Chris Croughton
Guest
Posts: n/a
 
      04-07-2005
On Thu, 7 Apr 2005 02:36:30 -0500, Ramzy Darwish
<(E-Mail Removed)> wrote:

> Maybe I didn't explain myself very well. I understand binary numbers and how
> to work with them, and I know how to work with memory in terms of allocating
> and deallocating and taking care of memory leaks and all of that. What I was
> referring to were the tricks I see people play with using bit patterns to
> determine mathematical properties of numbers (i.e. 1 then all 0's equal
> power of two, etc.).


Well, 00010000... is a power of the base in any base, how did you not
know that? The most 'obscure' one I've come across is that

a & (a-1)

removes the bottommost set bit, and that does need some thought.

> I know all about bases and took my architecture courses. I was just looking
> for a book that maybe helped one to try to look at a lower level than say
> objects or structs or something similar.


The operations are simple, if you already understand binary and "know
all about bases" (assuming 'bases' in the mathematical sense).

<< shift left (multiply by a power of 2 modulo 2^n)
>> shift right (divide by a power of 2 modulo 2^n)

& and the numbers (intersection)
| or the numbers (union)
^ exclusive or the numbers (difference)
~ invert the bits

The rest is mathematics. Mostly arithmetic...

Chris C
 
Reply With Quote
 
Jason Curl
Guest
Posts: n/a
 
      04-07-2005
Ramzy Darwish wrote:
> Maybe I didn't explain myself very well. I understand binary numbers and how
> to work with them, and I know how to work with memory in terms of allocating
> and deallocating and taking care of memory leaks and all of that. What I was
> referring to were the tricks I see people play with using bit patterns to
> determine mathematical properties of numbers (i.e. 1 then all 0's equal
> power of two, etc.).
>
> I know all about bases and took my architecture courses. I was just looking
> for a book that maybe helped one to try to look at a lower level than say
> objects or structs or something similar.
>

Do you have examples of the questions they asked? This makes it easier
for me to understand what you mean by "low-level" C, whether it's
pointer arithmetic, or bitshifting, or what ever else.

Cheers,
Jason.
 
Reply With Quote
 
Jonathan Bartlett
Guest
Posts: n/a
 
      04-07-2005
> What I want to know is how all of you out there learned the tricks that I
> see you propose to questions dealing with C on a binary number level, or
> actually using facts about the memory address of some data stored in memory.


I actually wrote my book on assembly language with people like you in
mind. It's called Programming from the Ground Up and is available at
http://www.cafeshops.com/bartlettpublish.8640017 and it gently
introduces you to things such as stacks, activation records, system
calls, binary numbers, memory management, and linking. It uses assembly
so that you can get a taste of how the machine itself is working, but
its purpose is to help you in other programming languages besides assembly.

Jon
----
Learn to program using Linux assembly language
http://www.cafeshops.com/bartlettpublish.8640017
 
Reply With Quote
 
Stephen Sprunk
Guest
Posts: n/a
 
      04-08-2005
"Ramzy Darwish" <(E-Mail Removed)> wrote in message
news:Y3%4e.23099$(E-Mail Removed)...
> I have a Bachelors in CS and a Masters in Comp. Graphics. In all
> of my schoolwork, I used C and C++ and thought that I had a
> pretty good understanding of the language(s). But now, as I really
> am trying to find work as a C/C++ programmer, I am having trouble
> on programming interview tests when they start asking about low-
> level C stuff dealing with memory and binary numbers. Recently, I
> took a test for a SE position at Intel, which I of course was very
> excited about, but I am pretty sure I bombed the test as I didn't
> really know a lot of what they were asking and staying up all
> night scouring the internet did not produce satisfying results (i.e. I
> didn't get the job).


Since you were applying for a job at a processor vendor, I'll take a stab in
the dark and say many of the things they asked about may have been
implementation-specific things that you would not have learned in general C
classes. That you classify the questions as "low-level" stuff reinforces
that guess, but without some example questions it's hard to say.

For better or worse, implementation-specific details of how C works on a
particular architecture and OS are off-topic here.

> Do you just have to learn it along the way like a lot of the PERL
> tricks? Are there any books that teach you this stuff? Websites?


<OT>
IMHO, the best way to learn the sorts of things I _think_ you were asked is
to get comfortable with assembly on your platform so that you can study the
output from your favorite compiler, both with and without optimizations. In
the process you'll learn all sorts of implementation-specific and low-level
stuff that portable C code should never be dependent on, e.g. stack frames,
number representations, endianness, syscalls/API calls, etc.

Not that I think that's a good idea in general, but it's probably what a
processor vendor is looking for in an SE -- someone who can "help" their
customers write C code that's targeted specifically to one platform and can
thus abuse implementation-specific details to improve performance on their
own platform while killing portability to competitors' platforms. Or
perhaps write implementation-level code that could never be portable in the
first place, like an OS kernel or drivers.

That's not necessarily a bad thing as long as you _know_ you're writing
unportable code. The key is not doing it when you don't intend to.
</OT>

S

--
Stephen Sprunk "Those people who think they know everything
CCIE #3723 are a great annoyance to those of us who do."
K5SSS --Isaac Asimov


 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      04-08-2005
Stephen Sprunk wrote:
> "Ramzy Darwish" <(E-Mail Removed)> wrote in message
>
>> I have a Bachelors in CS and a Masters in Comp. Graphics. In all
>> of my schoolwork, I used C and C++ and thought that I had a
>> pretty good understanding of the language(s). But now, as I really
>> am trying to find work as a C/C++ programmer, I am having trouble
>> on programming interview tests when they start asking about low-
>> level C stuff dealing with memory and binary numbers. Recently, I
>> took a test for a SE position at Intel, which I of course was very
>> excited about, but I am pretty sure I bombed the test as I didn't
>> really know a lot of what they were asking and staying up all
>> night scouring the internet did not produce satisfying results
>> (i.e. I didn't get the job).

>
> Since you were applying for a job at a processor vendor, I'll take
> a stab in the dark and say many of the things they asked about may
> have been implementation-specific things that you would not have
> learned in general C classes. That you classify the questions as
> "low-level" stuff reinforces that guess, but without some example
> questions it's hard to say.


On the contrary, from where I stand it sounds as if the OPs
education was sadly lacking in fundamentals. Memory and binary
numbers are pretty fundamental. Something like memorizing the
addition and multiplication tables in grade 2.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson


 
Reply With Quote
 
John Smith
Guest
Posts: n/a
 
      04-08-2005
WHO CARES IF IT IS OFF TOPIC.

Arse



"Stephen Sprunk" <(E-Mail Removed)> wrote in message
news:1112924741.e1b3d42254efab4d3ad97e06bf078191@t eranews...
> "Ramzy Darwish" <(E-Mail Removed)> wrote in message
> news:Y3%4e.23099$(E-Mail Removed)...
> > I have a Bachelors in CS and a Masters in Comp. Graphics. In all
> > of my schoolwork, I used C and C++ and thought that I had a
> > pretty good understanding of the language(s). But now, as I really
> > am trying to find work as a C/C++ programmer, I am having trouble
> > on programming interview tests when they start asking about low-
> > level C stuff dealing with memory and binary numbers. Recently, I
> > took a test for a SE position at Intel, which I of course was very
> > excited about, but I am pretty sure I bombed the test as I didn't
> > really know a lot of what they were asking and staying up all
> > night scouring the internet did not produce satisfying results (i.e. I
> > didn't get the job).

>
> Since you were applying for a job at a processor vendor, I'll take a stab

in
> the dark and say many of the things they asked about may have been
> implementation-specific things that you would not have learned in general

C
> classes. That you classify the questions as "low-level" stuff reinforces
> that guess, but without some example questions it's hard to say.
>
> For better or worse, implementation-specific details of how C works on a
> particular architecture and OS are off-topic here.
>
> > Do you just have to learn it along the way like a lot of the PERL
> > tricks? Are there any books that teach you this stuff? Websites?

>
> <OT>
> IMHO, the best way to learn the sorts of things I _think_ you were asked

is
> to get comfortable with assembly on your platform so that you can study

the
> output from your favorite compiler, both with and without optimizations.

In
> the process you'll learn all sorts of implementation-specific and

low-level
> stuff that portable C code should never be dependent on, e.g. stack

frames,
> number representations, endianness, syscalls/API calls, etc.
>
> Not that I think that's a good idea in general, but it's probably what a
> processor vendor is looking for in an SE -- someone who can "help" their
> customers write C code that's targeted specifically to one platform and

can
> thus abuse implementation-specific details to improve performance on their
> own platform while killing portability to competitors' platforms. Or
> perhaps write implementation-level code that could never be portable in

the
> first place, like an OS kernel or drivers.
>
> That's not necessarily a bad thing as long as you _know_ you're writing
> unportable code. The key is not doing it when you don't intend to.
> </OT>
>
> S
>
> --
> Stephen Sprunk "Those people who think they know everything
> CCIE #3723 are a great annoyance to those of us who do."
> K5SSS --Isaac Asimov
>
>



 
Reply With Quote
 
Randy Howard
Guest
Posts: n/a
 
      04-08-2005
In article <Y3%4e.23099$(E-Mail Removed)>,
http://www.velocityreviews.com/forums/(E-Mail Removed) says...
> What I want to know is how all of you out there learned the tricks that I
> see you propose to questions dealing with C on a binary number level, or
> actually using facts about the memory address of some data stored in memory.


This is interesting, as people complain about the lack of such
training in current degree programs fairly often, especially over
in comp.programming. You see, there was a time when this sort of
thing was a REQUIREMENT to make it through your degree program,
at least in the decent technical programs, particular CS, EECS,
etc. Maximizing tuition income seems to be more of a priority
for universities today, based upon this sort of thing coming up
all too frequently.

Many people learn this stuff over time on their own, before, during,
and after such coursework by writing software. The experience,
provided you aren't spending all your time painting forms in a web
browser and calling that programming, is likely to expose you to this
stuff gradually over time.

Working in a group of more experienced programmers willing to
mentor you is also a good way to pick it up. It sounds like
what you need right now is a crash course to get you up to
speed for interviews.

> I just ordered "Computer Systems: A Programmer's Perspective" and
> "Illustrating C".
> Of course I have K&R and Stroustrup, but they don't really go into this type
> of stuff in detail (and I didn't expect them to).


If you want it all in one place, try googling for HAKMEM, or a
somewhat easier read, but perhaps more interesting overall with
similar content in book form called "Hacker's Delight" by Henry
Warren. The term "hacker" in the title does NOT refer to people
breaking into computer systems in silly Hollywood movies, but the
real meaning of the word hacker.
ref: http://www.catb.org/~esr/faqs/hacker-howto.html

> Do you just have to learn it along the way like a lot of the PERL tricks?


If you think they're tricks, you may not be learning them, but just
memorizing. You'll find that won't get you very far in the real
world. Understanding them means you'll be able to start from
some you already know and derive a new one when needed to solve
a novel problem. There are not many useful preordained "checklists"
in real programming to fall back on as a crutch. You can't go down
to your local bookstore and buy Cliff Notes on writing file systems,
or laminated sheets explaining the intricacies of project design.

> Are there any books that teach you this stuff? Websites? Any help is
> appreciated.


Probably the best place to start is Hacker's Delight if you want a
book. If you want to test the waters a bit first, find a copy of
HAKMEM and look it over.

--
Randy Howard (2reply remove FOOBAR)
"Making it hard to do stupid things often makes it hard
to do smart ones too." -- Andrew Koenig
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Good Books To learn C++ psr C++ 15 02-28-2013 07:42 PM
Can anyone recommend some good books to learn Java programming with? Zer0 Voltage Java 5 06-27-2011 04:59 PM
Books, books, books: best reference texts for Verilog and VHDL HDL Book Seller VHDL 0 12-01-2004 02:26 AM
Books, Books, Books... C++ 3 09-19-2004 10:11 PM
newbie question: should I learn TKinter or skip it and learn more advanced toolkit? Porky Pig Jr Python 3 05-12-2004 08:58 AM



Advertisments