please help
need a code tht calculates number of hits
and misses in the cache from a adddress file with addresses stored as hexadecimals stored on th hard drive.these hexadecimals should first be changed into binary..
ive read some psuedo codes buh i seriosly dont know were to begin
the cache size is 128bytes and has cache blocks of 16bytes and the address space is 32bits.

i saw this code somewhere i tried to compile gave a lot of errors

public static void main(String[] args)
    	 	{
    	 		
    	 		// If the number of command line arguments is not right
    	 		// print out usage instructions and bail out.

          if (args.length != 3 && args.length != 4)
	    {  
            printUsage();
            }
        else
      	 { 
				// Run the simulation.            
				// Get the number of cache blocks from the first command line
                // argument. If it is not a power of two, then print an error
                // message followed by usage instructions and bail out.

            int blocks = Integer.parseInt(args[0]);
 
            double bits = Math.log(blocks) / Math.log(2);

            if (bits != (int) bits)
		 {

                  System.out.println("Error: <blocks> must be a power of 2.");
 
                  System.out.println();

                  printUsage();
                  }
                      
                // Get the size of a cache block in bytes from the second 
                // command line parameter. If it is not a power of two, then 
                // print an error message, usage instructions and then bail.


            int size = Integer.parseInt(args[1]);
 
            bits = Math.log(size) / Math.log(2);
 
            if (bits != (int) bits)
		 {
                  System.out.println("Error: <size> must be a power of 2.");
 
                  System.out.println();
   
                  printUsage();

                 }

               // Get the filename and possibly a boolean value indicating
               // what type of cache to use.  If the boolean is omitted 
               // then it is assumed that the cache is direct mapped.

            String filename = args[2];
  
            boolean assoc = false;
    
            if (args.length == 4)
                {
  
                 assoc = Boolean.valueOf(args[3]).booleanValue();

                }
           try 
               {

                FileReader inReader = new FileReader(filename);

                BufferedReader bReader = new BufferedReader(inReader);



                // Create the appropriate type of cache.

                Cache cache;

                  if (!assoc)
                   {

                    cache = new DirectMappedCache(blocks, size);

                   }


                  else
                   {

                    cache = new FullyAssociativeCache(blocks, size);

                   }

  
    
                int requests = 0;

                int hits = 0;


                while (bReader.ready())
                   {

  
                   // Read each line of the input file and convert 
 
                   // it to an int value.


                    String line = bReader.readLine();

                    int addr = Integer.parseInt(line);



                   // If the address is -1 interpret that as a command to
 
                   // print the cache contents using the dump method.


                    if (addr == -1)
                     {

                      cache.dump();

                     }

                    else
                     {

                        // If the address is not -1 then issue the address to

                        // the cache as a request.  If the request results

                        // in a cache hit then count it.


                        requests++;

 
                       if (cache.request(addr))
                        {

                         hits++;

                        }

                     }

                }


                // Report the results of the simulation.

                System.out.println("Total Requests: " + requests);

                System.out.println("Cache Hits: " + hits);

                System.out.println("Hit Rate: " + ((double) hits)/ requests);

                System.out.println();
 
            }

            catch (IOException e)
            {

                System.out.println(e);

                System.exit(-1);

            }

        }

    }


    private static void printUsage()
     {

        System.out.println("Usage: java CacheSim <blocks> <size> <file> [<assoc>]");

        System.out.println("<blocks>: # of cache blocks (must be a power of 2).");

        System.out.println("<size>: Size of each cache block (must be a power of 2).");

        System.out.println("<file>: The file containing reference stream.");

        System.out.println("<assoc>: Omitted or false for direct mapped cache,");

        System.out.println("true for fully associative cache.");

        System.exit(-1);
 
   }

}

So what is your question? Dumping some code that you found on the internet and can't compile isn't really what we mean about showing some effort if you expect to get any help.

> need a code tht ...
You've come to the wrong place if you expect anyone to just hand you code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.