Subject: RE: x86 assembly
To: , <netbsd-help@NetBSD.org>
From: Conrad T. Pino <NetBSD-Current@Pino.com>
List: netbsd-help
Date: 05/22/2004 09:17:22
From: Madhvesh R S
> 
> I have written one x86 assembly program in which 
> i am comparing the results of %eax with code fragment1
> as indicated below. Meanwhile can i replace this
> code fragment1 with code fragment2 by assuming that
> %eax contains -1 as return value before executing any
> of the code fragments
> 
> Code Fragment 1:
> 	test %eax, %eax
> 	jl sys_error
> 
> Code Fragment 2:
> 	cmpl $-4095, %eax
> 	jae sys_error	

I'm going to rewrite to avoid ambiguity:

label:	.int	145

frag1:
	mov	label(,1), %eax
	test	%eax, %eax
	jl	sys_error

	/* Jump if label: .int value less than 0 */

frag2:
	mov	-1, %eax
	cmp	label(,1), %eax
	jae	sys_error

	/* Jump if label: .int value not equal -1 */

They don't look equivalent to me.