Jump to content

Help - Assembly: counting lower/upper case chars from string

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Treymac

Treymac

    Newbie

  • Members
  • Pip
  • 3 posts
Hey guys. This is my first post here.

I'm learning assembly and I'm trying to develop is one program that counts the number of lower and upper case characters that are located in STRING1, and store the result in memory. The string, STRING1, consists of lower and upper case characters. I have to read 20 bytes of the the character date stored in STRING1, and count the number of lower and upper case characters, then store them in UPPER and LOWER.

Can anybody help me out here? I have a faint idea of how to go about creating the loop, but I have no idea of how to determine if the character is lower case or upper case.
I'm programming for 80x86 Intel.

Thanks a lot.

#2
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
You can compare two values using the cmp-instruction, and then use the different jump-instructions.
# AT&T syntax

cmp $0x41, character
jl  not_uppercase
cmp $0x5A, character
jg  not_uppercase

# 'character' is lowercase...
; Intel syntax

cmp character, 0x41
jl  not_uppercase
cmp character, 0x5A
jg  not_uppercase

; 'character' is lowercase...
41 and 5A are the hexadecimal-values for 'A' and 'Z' respectively.