Subject:
|
Re: The standard NXT firmware & the case of the missing opcodes
|
Newsgroups:
|
lugnet.robotics.nxt.nxthacking
|
Date:
|
Wed, 22 Aug 2007 15:07:46 GMT
|
Viewed:
|
17587 times
|
| |
| |
In lugnet.robotics.nxt.nxthacking, Jason J Railton wrote:
> In lugnet.robotics.nxt.nxthacking, Jason J Railton wrote:
>
> > > //Family: Bit manipulation
> > > #define OP_CMNT 0x0A // dest, src
> > > #define OP_LSL 0x0B // dest, src
> > > #define OP_LSR 0x0C // dest, src
> > > #define OP_ASL 0x0D // dest, src
> > > #define OP_ASR 0x0E // dest, src
> > > #define OP_ROTL 0x0F // dest, src
> > > #define OP_ROTR 0x10 // dest, src
I don't think I ever got around to mentioning this here, but a long time ago I
implemented all of the above opcodes in my NBC/NXC enhanced standard NXT
firmware. I implemented all of the shift opcodes so that they take 3 parameters
rather than just two as shown in the comments above. I'm not sure I mentioned
also that I implemented OP_ABS and OP_SIGN as well. As already mentioned
elsewhere I also implemented OP_WAIT and OP_WAITV (which takes a variable rather
than an immediate value).
I bring this up today because yesterday I implemented some more opcodes in the
NBC/NXC enhanced standard NXT firmware. New as of the lms_arm_jch.zip that I
uploaded yesterday are these opcodes:
OP_STOPCLUMPIMMED
OP_STARTCLUMPIMMED
OP_PRIORITY
OP_FMTNUM
Previously, in NBC and NXC I had implemented a compiler-based implementation of
the old NQC start keyword. In NBC you could use "start" as if it were a real
opcode in the firmware VM and under the hood NBC would generate the necessary
code to make it work 99% of the time. Now, using the latest test release of
BricxCC/NBC and this new enhanced standard firmware release you can use a real
start opcode in the VM. You will need to pass -EF to the compiler so that it
generates code designed to run on the enhanced firmware.
The NBC opcode is still just called "start". NBC already has a "stop" opcode
which stops the entire application if its boolean argument is true so I couldn't
use "stop" for stopping a thread. Instead I chose "stopthread" as the name of
the opcode in NBC. Use "priority" for the new opcode that lets you set the
priority of another thread (or your own thread). By default all threads in the
NXT VM have a priority of 20. A thread will always operate with a priority of at
least 1. The fmtnum opcode takes a byte array as its first (output) argument, a
byte array as its second argument (the format string), and a scalar variable as
its third argument. It uses sprintf internally to write the formated number to
the buffer provided.
Here's a sample NBC program that uses these new opcodes:
thread main
start normal
exit
endt
thread normal
start goofy
wait 2000
priority goofy, 1
wait 2000
priority goofy, 10
wait 10000
priority goofy, 30
wait 500
TextOut(0, LCD_LINE8, 'stop goofy')
stopthread goofy
TextOut(0, LCD_LINE7, 'goofy stopped');
wait 2000
exit
endt
thread goofy
dseg segment
i slong
buf byte[]
dseg ends
set i, 0
goofyLoop:
add i, i, 1
fmtnum buf, 'count = %d', i
TextOut(0, LCD_LINE1, buf)
jmp goofyLoop
exit
endt
John Hansen
|
|
Message has 2 Replies:
Message is in Reply To:
6 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
|
|
|
|