To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 2713
2712  |  2714
Subject: 
Re: anyone know how to check free space on RCX?
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Thu, 11 Jul 2002 19:34:00 GMT
Viewed: 
2235 times
  
That is very interesting Jason.  It is interesting that mm_free_mem()
returns a 16bit value using a 32bit return code.  Both int and long are
32bit value on most computers/compilers these days;  short would be a 16bit
value;  and char would be an 8bit value.  Maybe mm_free_mem() should return
an unsigned short instead.

I have used lcd_int and cputw to display 32bit values (although I am not
sure if lcd_int displays the value in hex or dec.  I may be wrong about it
displaying hex).  So lcd_int is looking only at the first word, whereas
cputw is looking at the second word.

Thank you for pointing this out!  I guess the next step is to check the
instruction timing for using 16bit values vs 32bit values.  If the
instruction timing is roughly the same, it may be worth updating some of the
code to use unsigned short instead of int or unsigned int.  On the other
hand, if a new RCX is released with more memory, we could run into problems.

// Joe

"Jason Clark" <yankeejason@comcast.net> wrote in message
news:Gz3GIL.C9q@lugnet.com...
While the declaration for mm_free_mem is
  int mm_free_mem(void)
The fact is that the RCX has only 32K of memory available.  32K in hex is
0x8000... there's never a need for more than 4 digits in hex.  Looking at
key_handler() in kernel/program.c (the system key handler), the code for
displaying free memory is (kernel v0.2.6, no patches):

/*
* pressing the "view" button cycles through a display of the
* amount of the amount of free memory (in decimal and
* hexadecimal) and battery power. If a button other than "view"
* is pressed while cycling through, we handle that button
* ("goto gotkey").
*/
cputs("free");
if ((c = getchar()) != KEY_VIEW) goto gotkey;
lcd_int(mm_free_mem());
if ((c = getchar()) != KEY_VIEW) goto gotkey;
cputw(mm_free_mem());
if ((c = getchar()) != KEY_VIEW) goto gotkey;


The first call to mm_free_mem() is displayed as an integer via lcd_int(),
the second call is displayed as a hexword via cputw().  The two values are
the same... mm_free_mem() is just being called twice.

-Jason



In lugnet.robotics.rcx.legos, Joseph Woolley writes:
Albert Huang,

Sorry for the confusion.  "most significant" = upper 16 bits and "least
significant" = lower 16 bits (the free memory is a 32 bit value).

If you write the values out, you will get the 32 bit value (both values • are
hex) ... for example:

999C + 54A0 = 999C54A0

// Joe

"Albert Huang" wrote
Joseph,

what do you mean by most significant / least significant?  I'm under • the
impression that those two calls just display the same value, in decimal
first and then in hex.

Cheers,
Albert





Message has 2 Replies:
  Re: anyone know how to check free space on RCX?
 
(...) int is defined as the natural width of the processor, which on a 16-bit processor is 16 bits. longs are 64 bits on some machines as well, so you can't assume it is always 32 bits -- if your code cares, use sizeof. (...) 32-bit math on the H8 (...) (22 years ago, 12-Jul-02, to lugnet.robotics.rcx.legos)
  Re: anyone know how to check free space on RCX?
 
(...) According to config/h8300/h8300.h in the gcc sources, int is 32bit for the h8 cross compiler. I believe the reason mm_free_mem() returns an int is because the memory manager stores the size of each free block as size_t, which is defined in (...) (22 years ago, 12-Jul-02, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  Re: anyone know how to check free space on RCX?
 
While the declaration for mm_free_mem is int mm_free_mem(void) The fact is that the RCX has only 32K of memory available. 32K in hex is 0x8000... there's never a need for more than 4 digits in hex. Looking at key_handler() in kernel/program.c (the (...) (22 years ago, 11-Jul-02, to lugnet.robotics.rcx.legos)

13 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR