Author 
Message 
George Morriso #1 / 59

Comus for obtaining carry flag?
Is there a method in common usage for obtaing the carry flag from the most recent arithmetic operation?  George Morrison Aberdeen, Scotland

Sat, 08 Nov 2003 02:18:57 GMT 


Jeff Fo #2 / 59

Comus for obtaining carry flag?
Quote: > Is there a method in common usage for obtaing the carry flag from the > most recent arithmetic operation?
Not in standard Forth. Chuck included the carry bit in the top of the stack in his chips which means that one can test for carry not only in the last operation, but in any operation from the past. Chuck included an opcode to test for carry in the instruction set, Czero, which branches on nocarry. This then maps to the words IF WHILE and UNTIL in Machine Forth which work, more or less, like IF WHILE UNTIL. If you don't have the extra bit on the stack, an unusual architectural feature, one could test for carry in the processor's carry flag from the last operation in some CODE inside of your own IF WHILE UNTIL words. This has been the practice for a decade in Machine Forth.

Sat, 08 Nov 2003 02:35:36 GMT 


a.. #3 / 59

Comus for obtaining carry flag?
: Is there a method in common usage for obtaing the carry flag from the : most recent arithmetic operation? Effectively, yes. M+ saves the carry on top of the stack, as does M*. Andrew.

Sat, 08 Nov 2003 03:10:14 GMT 


Jeff Fo #4 / 59

Comus for obtaining carry flag?
Quote:
> : Is there a method in common usage for obtaing the carry flag from the > : most recent arithmetic operation? > Effectively, yes. M+ saves the carry on top of the stack, as does M*.
Yes, but only for the mixed math operations. In those words the carry flag gets a whole cell. I was thinking of the reading the processor's carry flag after any math operation. But of course that is the standard way to do extended precision math operations. There is also M*/ and with these words you get doubles. One can treat the high word as a flag, but it is more than just a carry flag.

Sat, 08 Nov 2003 03:41:46 GMT 


Jerry Avin #5 / 59

Comus for obtaining carry flag?
Quote:
> Is there a method in common usage for obtaing the carry flag from the > most recent arithmetic operation? >  > George Morrison > Aberdeen, Scotland
There can be no portable method. The instructions that affect carry differ among processors, and there are some without one. (I never thought much about how such a one might be programmed.) The code to get carry into a flag probably has to be close to the lowlevel arithmetic operation itself, because subsequent operations can change it. Does anyone know of a highlevel language that includes access to flags like carry and overflow? I don't. Jerry  Engineering is the art of making what you want from things you can get. 

Sat, 08 Nov 2003 05:50:34 GMT 


Jerry Avin #6 / 59

Comus for obtaining carry flag?
Quote:
> : Is there a method in common usage for obtaing the carry flag from the > : most recent arithmetic operation? > Effectively, yes. M+ saves the carry on top of the stack, as does M*. > Andrew.
SwiftForth 2.00.3 19may2000 1. 2 m+ .s 3 0 <Top ok d. 3 ok Where is carry? Jerry  Engineering is the art of making what you want from things you can get. 

Sat, 08 Nov 2003 05:55:16 GMT 


Marcel Hendr #7 / 59

Comus for obtaining carry flag?
Jerry asked: Quote: > Does anyone know of a highlevel language that includes access to > flags like carry and overflow? I don't.
Occam? Maybe aph still remembers. marcel

Sat, 08 Nov 2003 06:34:16 GMT 


Jeff Fo #8 / 59

Comus for obtaining carry flag?
Quote:
> Does anyone know of a highlevel language that includes access to flags > like carry and overflow? I don't.
If you ask Chuck Moore he will say Forth. But not in the first 20 years of its history.

Sat, 08 Nov 2003 07:15:04 GMT 


Samuel A. Falvo #9 / 59

Comus for obtaining carry flag?
Quote:
>Where is carry?
Right here: Quote: >1. 2 m+ .s >3 0 <Top ok
^  Now try adding this: ( in GForth this works, at least ) HEX FFFFFFFF. M+ DECIMAL .S You'll find the result to be 1 1<top, where the topmost 1 is the carry.  KC5TJA/6, DM13, QRPL #1447 Samuel A. Falvo II Oceanside, CA

Sat, 08 Nov 2003 07:21:40 GMT 


Neil Baw #10 / 59

Comus for obtaining carry flag?
Quote:
>> Is there a method in common usage for obtaing the carry flag from the >> most recent arithmetic operation? >>  >> George Morrison >> Aberdeen, Scotland > There can be no portable method. The instructions that affect carry > differ among processors, and there are some without one. (I never > thought much about how such a one might be programmed.) The code to get > carry into a flag probably has to be close to the lowlevel arithmetic > operation itself, because subsequent operations can change it.
Quite true. The tests for carry and overflow should be easy to do in lowlevel, but that's not portable. Quote: > Does anyone know of a highlevel language that includes access to flags > like carry and overflow? I don't.
Add with carry is easy. : +CARRY ( x y  z carry ) 0 TUCK D+ ; Check for overflow is done by saving an operand and comparing the result unsigned. I'm too tired to remember or program how. ( 
http://www.wilbaden.com/ )

Sat, 08 Nov 2003 08:45:05 GMT 


Samuel A. Falvo #11 / 59

Comus for obtaining carry flag?
Quote: >( in GForth this works, at least ) >HEX FFFFFFFF. M+ DECIMAL .S
You know, someone is editing my posts. I really think this is true, because I *KNOW* I typed the following :) : HEX FFFFFFFF. 1 M+ DECIMAL .S  KC5TJA/6, DM13, QRPL #1447 Samuel A. Falvo II Oceanside, CA

Sat, 08 Nov 2003 13:42:17 GMT 


Bart Lateu #12 / 59

Comus for obtaining carry flag?
Quote: >You know, someone is editing my posts. I really think this is true, because >I *KNOW* I typed the following :) : >HEX FFFFFFFF. 1 M+ DECIMAL .S
If you expect this to return 1 1 , then you must have been thinking wrong.  Bart.

Sat, 08 Nov 2003 16:43:45 GMT 


a.. #13 / 59

Comus for obtaining carry flag?
:>
:> : Is there a method in common usage for obtaing the carry flag from the :> : most recent arithmetic operation? :> :> Effectively, yes. M+ saves the carry on top of the stack, as does M*. : Yes, but only for the mixed math operations. In those words the : carry flag gets a whole cell. Correct. An add with carry is a mixed math operation, isn't it? Andrew.

Sat, 08 Nov 2003 18:38:18 GMT 


a.. #14 / 59

Comus for obtaining carry flag?
: Jerry asked: :> Does anyone know of a highlevel language that includes access to :> flags like carry and overflow? I don't. : Occam? Maybe aph still remembers. Not Occam, no. Which reminds me: in one of my rare encounters with the great and the good, David Wheeler once complained to me about the inadequacies of modern programming languages in this regard. We'd been talking about high speed implementations of cryptographic algorithms and how hard it is to write efficient primitives in highlevel languages. Andrew.

Sat, 08 Nov 2003 18:43:53 GMT 


a.. #15 / 59

Comus for obtaining carry flag?
:>
:> : Is there a method in common usage for obtaing the carry flag from the :> : most recent arithmetic operation? :> :> Effectively, yes. M+ saves the carry on top of the stack, as does M*. : Yes, but only for the mixed math operations. In those words the : carry flag gets a whole cell. I was thinking of the reading the : processor's carry flag after any math operation. What carry flag? Lots of processors don't have one. Andrew.

Sat, 08 Nov 2003 18:45:09 GMT 

