I'm writing a loop as a part of a bigger program that checks if 2nd argument contains any uppercase letter (if yes, program quits). Here's what I have so far. I have marked the section of code I am having problems with.
%include "asm_io.inc"
SECTION .data
err1: db "Incorrect number of command line arguments",10,0
err2: db "2nd argument lenght more than 20",10,0
err3: db "Upper-case letter found!!!",10,0
strt: db "ho",10,0
SECTION .bss
N: resd 1
SECTION .text
global asm_main
asm_main:
enter 0,0
pusha
mov eax, dword [ebp+8]
cmp eax, dword 2
jne ERR1
mov ebx, dword [ebp+12] ; 24 to 37 calculates the length of 2nd argument
mov eax, dword [ebx+4]
mov edi, eax
sub ecx, ecx
sub al, al
not ecx
cld
repne scasb
not ecx
dec ecx
mov eax, ecx
cmp eax, dword 20
ja ERR2
mov [N], dword eax ;line 39 to 54 makes sure that all letters are lowercase
call print_int
mov ebx, N
call print_int
mov ebx, dword [ebp+12]
mov eax, dword [ebx+4]
;------------------------- Code that I am having problems with
LOOP:
mov bl, byte[eax]
cmp bl, 0x61
jb ERR3
cmp bl, 0x7A
jb ERR3
add eax, 4
add ecx,1
cmp ecx, N
jb LOOP
;---------------------------------------------------------------
mov eax, 0
mov eax, strt
call print_nl
call print_string
jmp asm_main_end
ERR1:
mov eax, err1
call print_string
jmp asm_main_end
ERR2:
mov eax, err2
call print_string
jmp asm_main_end
ERR3:
mov eax, err3
call print_string
jmp asm_main_end
asm_main_end:
call print_nl
popa
leave
ret
But even if my 2nd argument is abcd
, the loop still jumps to ERR3
. Any ideas what I might be doing wrong? I'm running redhat-linux, nas 2.10.07.
Edit: N is the length of the 2nd argument which is correct.