user3505631
user3505631

Reputation: 1

Jump instruction doesn't work

 data
 tekst: .ascii "heLLo WoRlD 93a9s\0"
 tekst_len = . - tekst
 .text
.global _start
   _start:
   mov $tekst_len, %edx
   petla:
cmp $tekst_len, %edx
je koniec 
cmpb $'a', tekst(,%edx,1)
jg zamien    #?????????????????????????????????????         
inc %edx
  jmp petla
  zamien:
  movb $'X', tekst(,%edx,1)
  inc %edx
  jmp petla
  koniec:
movl $4, %eax
movl $1, %ebx
movl $tekst, %ecx
movl $tekst_len, %edx
int $0x80 

I have such a problem: the instruction 'jg zamien' doesn't work. No matter what condition I choose 'jl', 'je' it never executes. Can someone tell me why?

Upvotes: 0

Views: 63

Answers (1)

Michael
Michael

Reputation: 58507

This is the reason:

mov $tekst_len, %edx
petla:
cmp $tekst_len, %edx  <-- edx will equal $tekst_len here on the first iteration
je koniec 

You're always jumping to koniec on the first iteration of the loop.

The mov should probably be mov $0,%edx.

Upvotes: 1

Related Questions