|
Okay, I'm working on a proc in ASM, and I need help with using MOV to move stuff
back and forth between memory and registers. I have the following (very simple)
program working, but I can't for the life of me get the MOV to work. I've got
the official software manual from Hitachi, and it explains how to transfer from
a memory location to a register, but I can't seem to get from a variable into
one.
#include <conio.h>
#include <unistd.h>
int main(int argc, char **argv) {
cputs("in");
sleep(1);
unsigned short total;
total = 10;
__asm__("
.text
.align 1
push.w r2
mov.b #0x00,r2h
mov.b #0x08,r2l
aloop:
add.b #0x01,r2h
cmp.b r2h,r2l
bge loopout
bra aloop
loopout:
pop.w r2
");
cputs("out");
sleep(1);
cls();
return 0;
}
|
|
Message has 1 Reply: | | 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
|
|
|
|