Jump to content
nevim

Ajutor ASM

Recommended Posts

Posted (edited)

Salut! Am si eu o intrebare de incepator in ASM x86 AT&T. Ideea este urmatoarea, vreau sa compar o variabila din memorie cu un numar, doar ca imi da un rezultat ciudat. Sigur imi scapa ceva, dar dupa vreo doua ore de debug si cautat pe net nu-mi dau seama despre ce e vorba. Nu stiu de ce intra pe jl.

 

.data
	n: .long 2
	gr: .asciz "gr"
	l: .asciz "l"
	e: .asciz "e"

.text


.globl _start


_start:
	mov $n, %eax
	mov $2, %ebx
	cmp %eax, %ebx
	jg lbl_gr
	jl lbl_l
	je lbl_e
	
	
	lbl_gr:
		mov $4, %eax
		mov $1, %ebx
		mov $gr, %ecx
		mov 3, %edx
		int $0x80
		jmp lbl_exit
	
	lbl_l:
		mov $4, %eax
		mov $1, %ebx
		mov $l, %ecx
		mov $2, %edx
		int $0x80
		jmp lbl_exit
	
	lbl_e:
		mov $4, %eax
		mov $1, %ebx
		mov $e, %ecx
		mov $2, %edx
		int $0x80
		jmp lbl_exit
		

lbl_exit:
mov $1, %eax
mov $0, %ebx
int $0x80

 

Ca sa rulez, am folosit:

as --32 cmp.asm -o cmp.o  
ld -m elf_i386 cmp.o -o cmp   

./cmp

 

Edited by nevim
Bad code

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...