View Single Post
Old Feb 2nd, 2005, 1:47 AM   #13
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4 lostcauz is on a distinguished road
Here's another using MASM.
; Count vowels, MASM 
; compiled using "console assemble and link" in Qeditor
.486                                    
.model flat, stdcall                    
option casemap :none                   
 
include \masm32\include\windows.inc    
include \masm32\macros\macros.asm       
include \masm32\include\masm32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\kernel32.lib

.data
    str1 db "aeiouAEIOU", 0
    str2 db "coUntsomevowEls", 0
    
.code          
             
start:   
    mov ecx, offset str1     ; load vowels
    mov edx, offset str2     ; load string
    xor esi, esi             ; zero vowel position counter
    xor edi, edi             ; zero string position counter
    xor ebx, ebx             ; number of vowels in word
l1: mov al, [ecx+esi]        ; begin loop, update vowel position
    cmp al, [edx+edi]        ; update string position
    jne @f                   ; not a vowel
    inc ebx                  ; is a vowel, count it
@@: inc esi                  ; increment vowel array position
    test al, al              ; check for terminator
    jne l1                   ; check all vowels
    inc edi                  ; next letter in word being checked
    cmp edi, [sizeof str2-1] ; test for end of string
    je  @f                   ; end of string
    xor esi, esi             ; reset vowel position counter
    jmp l1                   ; loop
@@: print str$(ebx)          ; print result to console
    exit
    
end start
__________________
-- lostcauz

Stepped in what?...
Behind whose barn?...
I didn't even know they had a cow!
lostcauz is offline   Reply With Quote