Thread: Studying computer architecture without knowledge of C-programming, got some questions

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    5

    Studying computer architecture without knowledge of C-programming, got some questions

    I'm on a foreign exchange program and studying computer architecture at university. The problem is this university it assumes the students have studied C-programming as their course in basic programming, whereas at my regular university the course in basic programming is ADA.

    I am trying to catch up but need some help since I don't really know how C-language is structured.

    My current problem:

    Shift operations, 32-bit.
    Got two functions

    int func1 (unsigned word)
    {
    return (int) ((word<<24) >> 24);
    }
    int func2 (unsigned word)
    {
    return ((int) word <<24) >> 24;
    }



    How does these functions work? I understand the logical shift but not the functions.

    My guess is func1 first shift all bits 24 bits to left, and then 24 bits to right, resulting in the 8 LSB will be the same but the 24 MSB will turn into 0's.

    Even if my guess is correct I can't see how func2 would work differently. I would greatly appreciate if someone could ellaborate for me.

    Examples with 127, 128, 255, 256 as in values?


    EDIT: Represented by two's complement
    Last edited by mrmeng; 09-18-2010 at 11:28 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New Computer = a few questions
    By Rune Hunter in forum Tech Board
    Replies: 4
    Last Post: 11-25-2004, 10:06 AM
  2. Computer will not boot.
    By RealityFusion in forum Tech Board
    Replies: 25
    Last Post: 09-10-2004, 04:05 PM
  3. Regarding Undergraduate Computer Majors
    By UnregdRegd in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 10-04-2003, 11:55 AM
  4. This is my last night on this computer.
    By joshdick in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 07-12-2003, 01:33 AM
  5. Which distro should I run on my old computer?
    By joshdick in forum Tech Board
    Replies: 5
    Last Post: 04-09-2003, 01:37 AM