To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.nxt.nxthackingOpen lugnet.robotics.nxt.nxthacking in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / NXT / NXT Firmware Hacking / 22
21  |  23
Subject: 
Re: The standard NXT firmware & the case of the missing opcodes
Newsgroups: 
lugnet.robotics.nxt.nxthacking
Date: 
Wed, 21 Mar 2007 17:34:27 GMT
Viewed: 
16786 times
  
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

Having used shifts in Z80 assembly before, I can see the uses of the different
types.  However, I can't see how I'd want anything other than arithmetical in
the NBC opcodes.  The only times I used logical, rotating, or with-carry-bit
shifts was for manipulating bitmap graphics, and I probably wouldn't be trying
to do that sort of thing in NBC.

As I understand it, << is an arithmetical shift left (shift bits up, fill with
0s) and >> is an arithmetical shift right (shift bits down, fill with whatever
the top bit was to preserve the sign for signed integers, or fill with 0s for
unsigned integers).

Again, for graphics it was always easier to use the <<= operation, to shift in
place.  But, on the odd occasion where I have used shifts in arithmetic, I'd
write the expression in the x=y<<z style.  Whether this makes any difference
once the expression is compiled to opcodes, I couldn't say.  If programming
directly in opcodes, I guess you just take whatever you can get.

Jason R

I guess what I'm saying is '<<=', 'OP_ASL' and 'OP_LSL' are all the same thing
(zero fill).

'>>=' means either 'OP_ASR' (smear fill) or 'OP_LSR' (zero fill) depending on
whether your target is signed or not.

If you wanted direct equivalents with C, you would have to say '>>=' means
'OP_ASR', and 'OP_ASR' should know the difference between signed (smear fill)
and unsigned (zero fill).

Jason R



Message has 1 Reply:
  Re: The standard NXT firmware & the case of the missing opcodes
 
(...) 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 (...) (17 years ago, 22-Aug-07, to lugnet.robotics.nxt.nxthacking)

Message is in Reply To:
  Re: The standard NXT firmware & the case of the missing opcodes
 
(...) Having used shifts in Z80 assembly before, I can see the uses of the different types. However, I can't see how I'd want anything other than arithmetical in the NBC opcodes. The only times I used logical, rotating, or with-carry-bit shifts was (...) (18 years ago, 21-Mar-07, to lugnet.robotics.nxt.nxthacking)

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
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR