[net.micro] 8086 et al status bits question.

roy@gitpyr.UUCP (Roy J. Mongiovi) (12/18/84)

I'm sort of curious about the possible reasons behind a little quirk
in the way the 8086 family of processors sets the status bits.  What
is the value of having the INC and DEC instructions set all the bits
EXCEPT for the carry flag?  I mean, there must be some reason, right?

Is it really useful to be able to do a comparison followed by an INC
(or DEC), and then be able to do a JC or JNC on the comparison?
-- 
Roy J. Mongiovi.	Office of Computing Services.		User Services.
Georgia Institute of Technology.	Atlanta GA  30332.	(404) 894-6163
 ...!{akgua, allegra, amd, hplabs, ihnp4, masscomp, ut-ngp}!gatech!gitpyr!roy

	  Who me?  I'm not even a REAL modo, I'm only a quasi-modo.

baba@spar.UUCP (12/19/84)

> 
> Is it really useful to be able to do a comparison followed by an INC
> (or DEC), and then be able to do a JC or JNC on the comparison?
> -- 

It makes the equivalent of the C "while(*pointer++ > VALUE)" construct 
more efficient.  In preserving only the carry flag it would appear that
intel learned from their mistake on the 8080, where 16-bit increments 
and decrements don't even affect the zero flag, forcing two additional
instructions into every 16-bit down-counter.

tim@cmu-cs-k.ARPA (Tim Maroney) (12/21/84)

Of course it is useful to set/clear the Z status bit in the 8080 on a DEC
instruction!  Loops that count down to zero are much easier.  Exemplia
gratia:

	mvi	b,limit
loop:
	; whatever the loop does
	dec	b
	jnz	loop

I wish they had done the same with DCX instructions, so you could count down
using 16-bit integers, but no, you have to go:

	lxi	b,limit16
loop:
	; whatever
	dcx	b
	mov	a,b
	ora	c
	jnz	loop

which is grodier to the nth degree.
-=-
Tim Maroney, Carnegie-Mellon University Computation Center
ARPA:	Tim.Maroney@CMU-CS-K	uucp:	seismo!cmu-cs-k!tim
CompuServe:	74176,1360	audio:	shout "Hey, Tim!"

"Remember all ye that existence is pure joy; that all the sorrows are
but as shadows; they pass & are done; but there is that which remains."
Liber AL, II:9.

wapd@houxj.UUCP (Bill Dietrich) (12/22/84)

I haven't used an 8080-type processor in 8 years or so,
but I believe the reason for INC/DEC not touching CARRY
is to allow multiple-digit or high-precision math.  To
add two 200 digit numbers, for example (in pseudo-code) :

	p1 = pointer to digit of number 1 (source)
	p2 = pointer to digit of number 2 (source)
	p3 = pointer to digit of number 3 (destination)
	*px means digit pointed to by px

	counter = 200
loop:
	add with carry *p1 and *p2 putting in *p3, generating carry
	INC p1
	INC p2
	INC p3
	DEC counter
	JUMP to loop if counter not zero


					Bill Dietrich
					houxj!wapd