
031/043 04 Nov 91 20:13:51
From:   Larry Mayhew
To:     David Welch
Subj:   Re: Bug
Attr:   
------------------------------------------------

 DW> For myself I had solved it years ago.  If you use a cmp ah,80h 
 DW> to set the flags.  A jc will jump if ah<80h and a jnc will jump 
 DW> if ah>=80h, along with jz and jnz, every combination is covered.
     
 DW> A jge will jump if SF=OF, jg will if SF=OF and ZF=0.  The carry 
 DW> flag CF is more straight foreward to me.
     
 Your last two sentences make it sound as though you're 
 recommending testing the carry flag as a substitute for 
 mnemonics such as jge.  

 If that isn't what you're saying, I don't know why you say 
 testing the carry flag is simpler ("more straight foreward").  
 Simplicity is irrelevant if jnc/jc don't do the same jobs as 
 jge/jl.  

 But if you're saying they _do_ do the same job, you've confused 
 the signed and unsigned conditional branches.  JNC/JC are 
 equivalent to (they generate _exactly_ the same machine language 
 as) JAE/JB.  Thus, to recommend that we replace JGE with JNC is 
 to recommend that we replace JGE with JAE.  That's basically the 
 confusion that started this whole thread off.  

 Even if you reformulate your point in terms of JAE/JB (instead
 of JGE/JL), I don't agree with your idea.  Your idea would then
 become that we should use JGE/JL for signed comparisons, but
 replace JAE/JB with JNC/JC.  There are two problems: 

 1.  Others expect you to use standard mnemonics for standard 
 operations.  Your use of JNC/JC as a substitute for JAE/JB will 
 thus make your code harder for others to follow.

 2.  Your claim would be that JC/JNC/JE/JNE cover all the cases.  
 But the useful cases include: JA/JAE/JB/JBE/JE/JNE, two of which 
 (JA and JBE) aren't directly covered by your mnemonics.  
 Equivalent tests can be implemented using your mnemonics, yes, 
 but at the cost of additional instructions.  It's hard to see 
 why anyone would want to use extra instructions to implement
 JA and JBE when they are already directly supported and their 
 meaning is clear.  But once we agree to use JA and JBE, what 
 point can there be to replace JAE with JNC and JB with JC?  

 Perhaps in the end we simply disagree about this, but my advice 
 to 8086 ASM programmers is to learn that "above/below" mnemonics 
 should be used for unsigned comparisons, which include address 
 comparisons, and, in most situations, character comparisons.  The 
 "greater than/less than" menemonics should be used for signed 
 comparisons.  Moreover, I'd advise programmers to preserve this
 distinction faithfully even when it makes no operational 
 difference to a program whether jge or jae is used.  
 Conceptually it makes a difference, and to the extent we haven't
 decided whether we're operating on signed or unsigned 
 quantities, we've left a hole of ambiguity through which subtle
 bugs can enter our software, because, among other things, we've
 left unclear the largest and smallest values our variables can
 contain.

--- Via Silver Xpress V2.26
 * Origin: COMM Port One HST/DS OPUSarchive (713) 980-9671 (1:106/2000)

