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 / 3647
3646  |  3648
Subject: 
Re: BrickOS Assembler
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 20 Jan 2004 16:01:50 GMT
Viewed: 
4035 times
  
In lugnet.robotics.rcx.legos, Mark Riley wrote:
Also, if you're going to use inline assembly code, the compiler needs to be
aware that variables can be changed by your code.  One way is to declare the
total variable as "volatile" like so:

  volatile unsigned char total;

Oh, I see. That's nifty. So a 'volatile' keyword ensures that it's reloaded
every time?

FYI, I believe there are other ways (besides the volatile keyword) to tell the
compiler about what your assembly code is doing, but I haven't delved that far
into the docs yet (look under the __asm__ keyword for more info).

Which doc is this? The only ones I have are the BrickOS command reference (it's
a shorter HTML one), and the software manual from Hitachi.

BTW, Kevin's suggestion of using the "-S" option with gcc is a good one, you can
learn a lot about H8 assembly just by seeing what the C compiler produces (you
can also learn what *not* to do! ;-)  A simple way to get the source file is to
type "make program.s" if your program is named program.c (I think you'll have to
modify the Makefile if you're using C++, though).

Yeah, I'll check that out. I couldn't get it to work when I tried it at first,
but I'll give a more sustained attempt tonight.

One final thing is about accessing local variables. I didn't have a problem
using offsets on a global array, but what about a local one? I could change the
structure of my program so that all the vars that need to be accessed in this
way are globals, but it would be much more straight forward to do it this way.
Particularly since the specific procedure is part of a recursive function.

Mike



Message has 1 Reply:
  Re: BrickOS Assembler
 
(...) Volatile tells the compiler that should assume the value can change without the compiler's knowledge. So yes, it gets reloaded every time. (...) To find this stuff, you need to read through documentation for GCC. It has been a few years since (...) (20 years ago, 21-Jan-04, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  Re: BrickOS Assembler
 
(...) Glad to help! (...) However, it *does* work for bytes... See the program below. In your example program, you declared the "total" variable as an unsigned short (which is a 16-bit word), but accessed it using an 8-bit move instruction. Instead, (...) (20 years ago, 20-Jan-04, to lugnet.robotics.rcx.legos)

11 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