4_CONDICION.s



# EJEMPLO DE CONDICION Y BRINCO
.data
	SI:	.string "SI SON IGUALES\n"
	NO:	.string "SON DIFERENTES\n"

.text
	.global main

main:
	mov	$5, %rax	# Se coloca en RAX el valor de 5
	mov	$20, %rbx	# Se coloca en RBX el valor de 20
	cmp	%rbx, %rax	# se comparan los contenidos (RAX - RBX)
	je	si		# son iguales? ir a etiqueta "si"
				# si no se cumple la condicion, continua a la
				# siguiente linea
	jmp	no		# salto incondicional ... ir a etiqueta "no"
	


fin:
	mov	$1, %rax	# SYS_CALL = 1 ( exit )
	mov	$0, %rbx	# valor devuelto a quien lo mando llamar
	int	$0x80		# llamada al sistema operativo

no:
	mov	$4, %rax	# SYS_CALL = 4 ( write )
	mov	$1, %rbx	# Manejador de archivo (stdout)
	mov	$NO, %rcx	# Cadena a imprimir
	mov	$15, %rdx	# Longitud de la cadena
	int	$0x80		# llamada al sistema operativo
	jmp	fin		# ir a etiqueta "fin"

si:
	mov	$4, %rax	# SYS_CALL = 4 ( write )
	mov	$1, %rbx	# Manejador de archivo (stdout)
	mov	$SI, %rcx	# Cadena a imprimir
	mov	$15, %rdx	# Longitud de la cadena
	int	$0x80		# llamada al sistema operativo
	jmp	fin		# ir a etiqueta "fin"