This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

converting to uppercase

iam trying to convert the char i received to uppercase if it is lowercase if not leave it asit is .
igot this code from net.
but unable to understand why they added #224 at the end.

org     0000h

        mov     acc,#'z'
        clr     c
        subb    a, #97
        jc      upper2
        subb    a, #26
        jnc     upper2
          add     a, #224

upper2: mov    r0,a
         end

Parents
  • First of all, do you have an ASCII chart showing the full range of ASCII codes (from 0x00 to 0x7F)?
    This is absolutely fundamental to understanding what's going on.

    Look at your ASCII table: what would you need to do to convert a lowercase character to uppercase?
    Think of a simple bitwise operation...

    Before you can apply this conversion, you have to test that your ASCII code actually is a lowercase character...

    "unable to understand why they added #224 at the end"

    Try thinking in Hex...

Reply
  • First of all, do you have an ASCII chart showing the full range of ASCII codes (from 0x00 to 0x7F)?
    This is absolutely fundamental to understanding what's going on.

    Look at your ASCII table: what would you need to do to convert a lowercase character to uppercase?
    Think of a simple bitwise operation...

    Before you can apply this conversion, you have to test that your ASCII code actually is a lowercase character...

    "unable to understand why they added #224 at the end"

    Try thinking in Hex...

Children