Newbie MIPS help

edited March 2005 in Internet & Media
Hi,

Im a real newbie at mips (only started learning)
im trying to write a program that does the below.
=================================================

Comments

  • mondimondi Icrontian
    edited March 2005
    check the hex value of each character, if its between 0x61 (a) and 0x7A (z)... then subtract 0x20 (A-Z = 0x41 -> 0x5A)

    that should do it.

    m
  • edited March 2005
    mondi wrote:
    check the hex value of each character, if its between 0x61 (a) and 0x7A (z)... then subtract 0x20 (A-Z = 0x41 -> 0x5A)

    that should do it.

    m
    hey mondi,

    any chance you could elaborate on that?? How do you read the hex value and alter it??

    thank you much!!
  • mondimondi Icrontian
    edited March 2005
    Actually theres a simpler way, no hex is actually needed (Im just used to thinking in those terms :))

    heres a quick example of what you'd want, bear in mind that my MIPS is terribly rusty, but it seems to work in pcspim alright ...

    [PHP]

    # vars
    .data
    ask_for_input: .asciiz "enter a string: "
    thestring: .asciiz ""

    .text
    main:

    # prompt
    li $v0,4
    la $a0, ask_for_input
    syscall

    # get input
    li $v0,8
    li $a1,30
    la $a0,thestring
    syscall

    li $v0,4
    li $t0,0

    # loop and check ...

    loop: lb $t1,thestring($t0)
    beq $t1,0,finished
    bgt $t1,122,continue #if $t1 > "z" (0x7A) skip subtraction
    blt $t1,97,continue #if $t1 < "a" (0x61) skip subtraction
    sub $t1,$t1,32 #else subtract 32 (0x20)
    sb $t1,thestring($t0)
    continue:
    addi $t0,$t0,1
    j loop


    finished:
    li $v0,4
    la $a0,thestring
    syscall

    li $v0,10
    syscall

    [/PHP]
  • edited March 2005
    :thumbsup:
Sign In or Register to comment.