Thread: MIPS Assembly Bubble Sort

  1. #16
    Registered User cornfeller's Avatar
    Join Date
    Sep 2011
    Location
    Orlando,Florida
    Posts
    10
    I changed my code up.. The sort was killing me and i couldn't figure it out. So now at least my code takes a string of letters and returns them capitalized. Now have to figure out a new sorting technique.

  2. #17
    Registered User cornfeller's Avatar
    Join Date
    Sep 2011
    Location
    Orlando,Florida
    Posts
    10
    heres the new code
    #
    #
    #
    #
    ################################################## #######################

    #----------------data---------------------------------------------------#

    .data

    string_ask: .asciiz "\nPlease enter your letters: "

    string_return: .asciiz "\nResult: "

    in_name: .space 31 ## space for input string


    ################################################## ##########################

    #---------------------print-input-question---------------------------------#

    .text

    .globl main

    main:

    la $a0,string_ask ## print prompt string

    li $v0,4

    syscall
    ################################################## ###########################

    #-------------------------reads-string-input--------------------------------#

    la $a0,in_name ## read the input string

    li $a1,31 ## at most 30 chars + 1 null char

    li $v0,8

    syscall
    ################################################## #############################
    #----------------------------------------------------------------------------#

    la $a0,string_return ## write output message

    li $v0,4

    syscall


    la $t0,in_name

    ################################################## ################################

    #-------------------------lower-to-upper-case------------------------------------#
    loop1:

    lb $t1,0($t0)

    beqz $t1,exit_loop1 ## if NULL, we are done

    blt $t1,'a',no_change ## $t1 < a

    bgt $t1,'z',no_change ## $t1 > z

    addiu $t1,$t1,-32 ## convert to uppercase: 'A'-'a'=-32

    sb $t1,0($t0)

    no_change:

    addiu $t0,$t0,1 ## increment pointer

    j loop1

    ################################################## ###################################

    #-----------------------------------------------------------------------------------#



    exit_loop1:

    la $a0,in_name ## output converted string

    li $v0,4
    syscall

    li $v0,10 ## exit
    syscall


    ################################################## ######################################
    #--------------------------------------------------------------------------------------#

  3. #18
    Registered User cornfeller's Avatar
    Join Date
    Sep 2011
    Location
    Orlando,Florida
    Posts
    10
    i want to put a sort function in this code, where should it be placed?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. convert c programm to mips assembly
    By mariakat in forum Tech Board
    Replies: 8
    Last Post: 02-14-2011, 08:39 PM
  2. Converting C into MIPS Assembly
    By clag in forum C Programming
    Replies: 5
    Last Post: 02-13-2010, 07:48 PM
  3. A question of the MIPS assembly program
    By ok_good in forum Tech Board
    Replies: 0
    Last Post: 05-03-2006, 10:13 PM
  4. bubble sort in assembly language using c++
    By lorenzohhh in forum C++ Programming
    Replies: 3
    Last Post: 04-15-2002, 09:06 PM
  5. bubble sort in assembly language!!!!!!
    By lorenzohhh in forum C++ Programming
    Replies: 1
    Last Post: 04-15-2002, 08:30 PM