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 / 3640
3639  |  3641
Subject: 
Re: BrickOS Assembler
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Sun, 18 Jan 2004 19:53:58 GMT
Viewed: 
4159 times
  
In lugnet.robotics.rcx.legos, Iain McInnes wrote:
1) Pass the variable to a function - the first function argument seems to be r0.

I need to access elements of a 2d array. I don't think this is an option for
that. Nevertheless, could you post code that demonstrates this?

You can easily experiment with this by inspecting the assembler output from gcc.

How do I do that?

2) Figure out the assembler idiom for referring to symbols and use that.

???

3) I spent a bit of time surfing around the existing code, and there seems to be
an assembler macro idiom where variables can be pasted directly into the
assembler.  I was too lazy to find the documentation on how to use it, but
someone might post here to tell you ;)

Hmm... this sounds more like what I'm trying to do. Someone?

#include <conio.h>
#include <unistd.h>

unsigned short total;

int main(int argc, char **argv) {


  cputs("hello");
  sleep(1);

  total = 255;

  __asm__("
  .text
  .align 1

    push.w r2
    push.w r3

    mov.b #0x00,r2h
    mov.b #0x08,r2l

    verticalxloop:

      add.b #1,r2h

      cmp.b r2h,r2l

      bge loopout

    bra verticalxloop

    loopout:

    mov.b r2h,@_total

    pop.w r3
    pop.w r2
  ");

  cputw(total);
  sleep(1);
  cls();

  return 0;
}

Here it compiles without an error, but it puts 00FF on the display, rather than
8. Obviously r2h was never actually moved into total at all...

Mike



Message has 4 Replies:
  Re: BrickOS Assembler
 
(...) Hi Mike, Check out the source for memcpy.c in the C library. It's not immediately clear, but the directives at the end of the __asm__ section beginning with "r" associate the %n macros with the given variables. I'm not sure of the exact syntax (...) (21 years ago, 18-Jan-04, to lugnet.robotics.rcx.legos)
  Re: BrickOS Assembler
 
(...) I recommend compiling with the -gstabs+ option (by modifying the makefile). After your .lx file is generated use "h8300-hms-objdump --disassemble-all --source > my.lst" to get a disassembled file with the C source intermixed.into the file (...) (21 years ago, 19-Jan-04, to lugnet.robotics.rcx.legos)
  Re: BrickOS Assembler
 
(...) In rethinking I think that compiling with the -S option will do what you want. It should create a file with a .s suffix. -S makes the compiler compile, but not assemble. Kevin "YOU ARE A GENIUS!!!!!! you can put that in your sig file!!!" Chris (...) (21 years ago, 19-Jan-04, to lugnet.robotics.rcx.legos)
  Re: BrickOS Assembler
 
(...) One more answer... :-) Mark #include <unistd.h> #include <conio.h> int x = 10; int y = 5; int z; int main() { __asm__(" mov @_x,r0 mov @_y,r1 add r1,r0 mov r0,@_z "); lcd_int(z); msleep(5); return 0; } (21 years ago, 19-Jan-04, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  Re: BrickOS Assembler
 
Hi, Michael. I had some trouble with getting variables into registers, as well. I can think of three ways: 1) Pass the variable to a function - the first function argument seems to be r0. You can easily experiment with this by inspecting the (...) (21 years ago, 18-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