negative hex

negative on a 32-bit processor and positive (if you assume hex constants to be signed on a 16-bit proceeor) or an overflow warning/error if you have a 16-bit processor and assume hex constants to be unsigned- since 0xFEEE is too big for an unsigned).

Usually 8-bit processor cross-compilers tend to pretend to be 16-bits.

Too many dubious ASSumptions.

Best regards, Spehro Pefhany

--
"it\'s the network..."                          "The Journey is the reward"
speff@interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Reply to
Spehro Pefhany
Loading thread data ...

This assembler uses longs (32 bit ints) internally, so if I want to plop a long into memory (.LONG) it just pokes what I type. I can imagine 0x80000000 as signed or unsigned... the assembler doesn't care. It does know how to complement and negate and stuff like that.

It treats 0x00008000 and 0x8000 as the same value, which makes sense to me.

It doesn't like to eval certain numbers as longs and then poke the low

16 bits into memory (.WORD directive)... it thinks I don't know what I'm doing. I'd perfer it to just use the low 16 bits and keep its opinions to itself.

One annoying case is making a 16-bit mask by complementing a constant, as "AND.W # ~0x2000, D3", which it tends to spike.

Since my question regards evaluating numeric values within user command strings, with no specific language or compiler implied, it makes sense to me to treat any 0xXXXX thing as positive, and any

-0xXXXX as negative. Specifically, I want users to be able to express DDS frequencies in decimal or hex, and I want them to be able to reliably select positive or negative frequencies.

John

Reply to
John Larkin

quantity

Only if you're using 16-bit ints and decide that they are signed. I consider 0xFEEE to be decimal +65262. My HP 32S calculator agrees.

negate it.

I want "-0x40000000" to program a generator to make -16.000 MHz.

John

Reply to
John Larkin

On a sunny day (Mon, 30 Jun 2008 11:55:27 -0700) it happened John Larkin wrote in :

Apart from connecting the '-' sign to a '-' sign in the frequency display, I have no idea what -16 MHz would be. Or shift 16 MHz down? Or 180 degrees phase flipped? What is a negative frequency?

Reply to
Jan Panteltje

In a DDS, negative frequency corresponds to putting a negative number into the phase accumulator. That walks a waveform table backwards. Waveforms then come out "inverted" in time. And if I create a polyphase waveform set that spins a motor clockwise, when I program the frequency to be negative, the motor will spin CCW. There are all sorts of uses for this.

It's equivalent to asking for a frequency past Nyquist, and using the resulting alias.

John

Reply to
John Larkin

On a sunny day (Mon, 30 Jun 2008 12:43:23 -0700) it happened John Larkin wrote in :

OK, got it (I think) never too old to learn :-)

Reply to
Jan Panteltje

The first and second errors you made are implementing in anything other than assembler. The third was using sign magnitude.

Reply to
JosephKK

There is good reason for that as well; it is the only system that leverages the existing ALU to the max for doing multiple byte / halfword / word / double-word and wider in a consistent manner. And you claimed to not understand hex regrouping of 2's compliment.

Reply to
JosephKK

Actually adding sign to hex numbers will more likely confuse your users. The standard binary interpretations are far better known. (int and unsigned int)

Reply to
JosephKK

Why don't you go whole hog and use 13's complement. See XS3 encoding.

Reply to
JosephKK

Hmm..

One person, writing a library that has to port to 10+ CPU's, in assembler, to build the basis of number-theoretic and cryptographic functions, knowing in advance that any error in implementation will result in catastrophic security breaches...

No thanks. :)

I wrote most of it in C++, and following Donald's Knuth's admonition that...

"Premature optimization is the root of all evil."

The time-critical operations were written in assembler.

In any case, all major Big-Integer libraries follow this pattern, including the current premiere library, GMP:

formatting link

Maple, OTOH, used base-10 internally for its big-number representation, IIRC from Henri Cohen's "A Course In Computational Algebraic Number Theory". That is a big mistake, IMHO.

In any case, I think you would find that the difference between C++/ assembler and assembler in terms of overall speed for the operations is minimal.

-Le Chaud Lapin-

Reply to
Le Chaud Lapin

It hasn't confused me for decades. Unlike to do so until i get senile.

Reply to
JosephKK

  1. >>>Not a negative option in sight.

Now I am confused. What is it that I claimed to not understand?

John

Reply to
John Larkin

Really? That is very clever! And how exactly does it store -0x80000000 in a 32 bit register? Complementing it is no problem but when you add one you are back exactly where you started.

Isn't there some way of casting the bit pattern to the required size. That way by making your intentions clear the assembler knows what you want. Too many people make mistakes with byte/word/long sizes.

Yes. But you still need to give consideration to the minor boundary problem of -MAXINT-1 which for 32 bits is 0x80000000 Compliment it and add one and you will understand.

Your parser probably should not allow -0x80000000 or have the defined behaviour that -0x80000000 == 0x7FFFFFFF since the 32 bit register cannot represent +MAXINT+1

Fence post errors like this are potentially dangerous. And ambiguities in specifications are worse.

Although you don't see the problem your users might be better off if the syntax was defined to only accept values in the range 0 to 0x7fffffff if the "-" sign is used (which is what the assembler was doing)

Otherwise you have things like -0xffffffff = +1 which they may not expect even if you do!

Regards, Martin Brown

** Posted from
formatting link
**
Reply to
Martin Brown

Well, I paid almost $80 for it.

It throws an error,

000000 0000 .WORD -0X80000000

C:\\JOBS\\_T_SER~1\\T344\\28E344B\\28E344B.ASM(128,28): Error 36 - Operand not in specified range

which I wish it wouldn't. Assemblers should be as dumb as possible and just manipulate the bits without making value judgements. My parser never declares errors, it just moves bits.

Yup, fine by me.

Actually, I understood that ca 1968, only it was 12-bit words.

Or I can just tell the users not to do that. The maximum legal positive frequency is 31.999999985 MHz, and 0x80000000 is already -32 MHz, so requesting -(-32 MHz), -0x80000000, and getting -32 MHz isn't really outrageous.

I suppose, but it is nice to be able to set exactly 32.000000 MHz. The hex thing is mostly for "sophisticated users", of which I might someday have a few.

Good grief, another appendix to the manual.

The DDS LSB is 64MHZ * N / 2^32, which is 14.901161etc mHz. So if a user wants channel 2 to be, say, 1 KHz and asks for it that way (ascii command 2Freq 1K) and wants channel 3 to be 5 KHz (3Freq 5K), and expects to set their relative phases (simulating, say, speed pickups in a geared turbine) he'll likely notice a slow phase creep caused by rounding the Hz input to the nearest DDS LSB. So being able to access the raw DDS accumulator values is something I have to provide, and explain, already.

John

Reply to
John Larkin

But, but - the "Sign EXtend" instruction is so much fun to code! ;-)

Cheers! Rich

Reply to
Rich Grise

Self-esteem. >:[

Thanks, Rich

Reply to
Richard The Dreaded Libertaria

They say they need a citation for the 0-9,u-z convention in the Bendix G-15 - Is just the fact that I've used one good enough? In fact, the school where I went to 11th grade had one - my first programming class was in 1965. :-)

It was a fascinating machine:

formatting link

Cheers! Rich

Reply to
Rich Grise

I learned steam in Thermodynamics class. I never tried to steam myself. eSteam must be some kind of internet enabled steam engine.

--
Jeff Liebermann     jeffl@cruzio.com
150 Felker St #D    http://www.LearnByDestroying.com
Santa Cruz CA 95060 http://802.11junk.com
Skype: JeffLiebermann     AE6KS    831-336-2558
Reply to
Jeff Liebermann

And? Were does it say anything about steam?

formatting link
"

Reply to
Jamie

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.