x86 - how to count small and large letters at the same time in assembly? -



x86 - how to count small and large letters at the same time in assembly? -

can help me assembly !? know how count letters, little or big one, cannot both @ once. below code counting little letters

mov bx, offset buff mov cl, [bx - 1] ;size of string mov dx, 0 ;reset dx cykluss: mov al, [bx] ;reading characters inc bx ;increasing char in string cmp al,'$' ; end of line? je supp cmp al,'a' jl cykluss ; if char < 'a' go start(cykluss) cmp al,'z' jg cykluss ; if char > 'z' go start(cykluss) inc dx jmp cykluss supp: mov bx,dx charp 10 ;macro new line phone call disp ;convert dx number

please help me give thanks much

just copy-paste , run.

to check lowercase , uppercase letters, have check if character between extreme letters : 'a' , 'z', if so, check if character greater or equal 'a', if so, it's lowercase letter, or, check if character less or equal 'z', if so, it's uppercase letter. idea? next code changes create run in emu8086 :

.stack 100h .data buff db 'ab[c*e-g^h#$' lower_counter dw 0 ;counter lowercase letters. upper_counter dw 0 ;counter uppercase letters. msj1 db 13,10,'lowercase letters : $' msj2 db 13,10,'uppercase letters : $' str db 6 dup('$') ;string store number. .code ;initialize info segment. mov ax,@data mov ds,ax mov bx, offset buff cykluss: mov al, [bx] ;reading characters inc bx ;increasing char in string cmp al,'$' ; end of line? je supp ;---check letters on extremes ('a','z'). cmp al,'a' ; if char < 'a' it's not letter. jl cykluss cmp al,'z' ; if char > 'z' it's not letter. jg cykluss ; if char > 'z' go start(cykluss) ;---check letters in middle ('z','a'). ;---remember : if next lines executed, means "al" ;---holds value between 'a' , 'z' (65..122). cmp al,'a' jge its_lowercase ; if char >= 'a' it's lowercase letter. cmp al,'z' jle its_uppercase ; if char =< 'z' it's uppercase letter. jmp cykluss ; if (char > 'z') , (char < 'a') it's not letter. its_lowercase: inc lower_counter jmp cykluss its_uppercase: inc upper_counter jmp cykluss supp: ;display total lowercase. mov ah, 9 mov dx, offset msj1 int 21h phone call dollars mov ax, lower_counter ;parameter number2string. phone call number2string ;result returns in "str". mov ah, 9 mov dx, offset str int 21h ;display total uppercase. mov ah, 9 mov dx, offset msj2 int 21h phone call dollars mov ax, upper_counter ;parameter number2string. phone call number2string ;result returns in "str". mov ah, 9 mov dx, offset str int 21h ;finish program. mov ax,4c00h int 21h ;------------------------------------------ ;number convert must come in in ax. ;algorithm : extract digits 1 one, store ;them in stack, extract them in reverse ;order build string. proc number2string mov bx, 10 ;digits extracted dividing 10. mov cx, 0 ;counter extracted digits. cycle1: mov dx, 0 ;necessary split bx. div bx ;dx:ax / 10 = ax:quotient dx:remainder. force dx ;preserve digit extracted later. inc cx ;increase counter every digit extracted. cmp ax, 0 ;if number jne cycle1 ;not zero, loop. ;now retrieve pushed digits. mov si, offset str cycle2: pop dx add together dl, 48 ;convert digit character. mov [ si ], dl inc si loop cycle2 ret endp ;------------------------------------------ ;fills variable str '$'. ;used before convert numbers string, because ;these strings displayed. proc dollars mov si, offset str mov cx, 6 six_dollars: mov al, '$' mov [ si ], al inc si loop six_dollars ret endp

what need check if al between 2 numeric ranges :

assembly x86

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

Using ajax with sonata admin list view pagination -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -