Created
March 11, 2014 15:51
-
-
Save taylorlapeyre/9488633 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* int i = 0; | |
* int nl = 0; | |
* while (S[i]) { | |
* if (S[i] > 97 && S[i] < 122) { | |
* nl++; | |
* } | |
* i++; | |
* } | |
*/ | |
/* | |
* my registers: %eax, %edx, %ecx | |
* other registers: %esi, %ebp, ... | |
*/ | |
#define II %edx | |
#define NL %eax | |
#define CH %cl | |
#define STR %esi | |
#define FSIZE 4 | |
.text | |
.globl _numLowerCase | |
_numLowerCase: | |
sub $FSIZE, %esp | |
movl %esi, (%esp) | |
movl FSIZE+4(%esp), STR | |
xor II, II | |
xor NL, NL | |
LOOP1: | |
movb (STR, II), CH | |
cmp $0, CH | |
je DONE | |
cmp $97, CH | |
jl SKIP | |
cmp $122, CH | |
jg SKIP | |
inc NL | |
SKIP: | |
inc II | |
jmp LOOP1 | |
DONE: | |
movl (%esp), %esi | |
add $FSIZE, %esp | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment