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 / 2715
2714  |  2716
Subject: 
Re: anyone know how to check free space on RCX?
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Fri, 12 Jul 2002 15:54:11 GMT
Viewed: 
2339 times
  
In lugnet.robotics.rcx.legos, Joseph Woolley writes:
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.

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 mem.h to be 'unsigned', i.e. unsigned int.
mm_free_mem() adds these blocks' sizes up and returns the result.  It is
interesting to note that <sys/mm.h> says:

#define MM_HEADER_SIZE 2   //!< 2 words header: pid, size

Indicating that the size of the block is stored in a word, and yet all the
code in mm.c treats the headers as a pair of size_t elements (i.e unsigned
or unsigned int).  Can anyone else comment on this?  I admit I'm still new
to legOS and the kernel sources, but it seems straightforward.  Why would
the memory manager use all ints when 32bit math is so much slower on an h8?
I feel like i'm missing something.


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.

cputw() accepts an 'unsigned', and displays the final 4 hex digits:

    for(i = 1; i < 4; i++) {
      cputc_hex(word & 0x0f, i);
      word >>=4;
    }

To display a 32bit value as two hex words, i would do this:
    cputw(myInt >> 8);
    sleep(1);
    cputw(myInt);

lcd_int() is actually a #define for a call to the ROM function lcd_number(),
which prevents me from inspecting the source code :P  The comments in
<rom/lcd.h> explain partially (it should display a signed integer, no
decimal), but I can't tell how overflowing the size of the LCD is handled.
And since I'm away from home visiting family, I am RCX-free this weekend
(yuck), so I can't conduct any tests just now.  I will probably write some
code next week to put these call through their paces, as well as check on
some data type sizes.

-Jason



Message has 2 Replies:
  Re: anyone know how to check free space on RCX?
 
(...) My sources (gcc-3.0) say: #define INT_TYPE_SIZE (TARGET_INT32 ? 32 : 16) A short experiment revealed that sizeof(short)=sizeof(int)=2, sizeof(long)=4. So int is normally 16bit. Only with the switch "-mint32" I get 32 bit ints. This is with a (...) (22 years ago, 12-Jul-02, to lugnet.robotics.rcx.legos)
  Re: anyone know how to check free space on RCX?
 
(...) This can't be right. I'm about 99% sure that all of the ints I've used with my legOS programs have been 2 bytes. When using LNP to send RCX ints to a PC, for example, you have to use short on the PC end of things to make it all work right. (...) (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?
 
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 (...) (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