Search
 
SCRIPT & CODE EXAMPLE
 

ASSEMBLY

sort in assembly pcspim

    .text
    .globl main
main:       la  $a0, Array             # sets the base address of the array to $a0
loop:       lw  $t0, 0($a0)             # sets $t0 to the current element in array
            lw  $t1, 4($a0)         # sets $t1 to the next element in array
            blt $t1, $t0, swap      # if the following value is greater, swap them
            addi    $a0, $a0, 4     # advance the array to start at the next location from last time
            j   loop                  # jump back to loop so we can compare next two elements

swap:       sw  $t0, 4($a0)         # store the greater numbers contents in the higher position in array (swap)
            sw  $t1, 0($a0)         # store the lesser numbers contents in the lower position in array (swap)
            li  $a0, 0                 # resets the value of $a0 back to zero so we can start from beginning of array
            j   loop                  # jump back to the loop so we can go through and find next swap

            .data

Array:      .word   14, 12, 13, 5, 9, 11, 3, 6, 7, 10, 2, 4, 8, 1 
Comment

PREVIOUS NEXT
Code Example
Assembly :: nano error reading lock file not enough data read 
Assembly :: gridbaglayout span 
Assembly :: google appscripts cell get background color 
Assembly :: array days of the week 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application 
Javascript :: electronjs require is not defined 
Javascript :: alphabet array 
Javascript :: regex cpf 
Javascript :: redirect javascript 
Javascript :: react refresh page 
Javascript :: react native build aab 
Javascript :: import redux thunk 
Javascript :: changing columns for table requires doctrine dbal install doctrine/dbal 
Javascript :: how to display object in alert javascript 
Javascript :: react native text underline 
Javascript :: change src of iframe jquery 
Javascript :: mongodb check for array not empty query 
Javascript :: how to check variable type jquery 
Javascript :: loop array backwards javascript 
Javascript :: remove commas from string javascript 
Javascript :: dynamics crm javascript set field visible 
Javascript :: jquery enforce important 
Javascript :: explode in jquery 
Javascript :: react navigation no header 
Javascript :: check if checkbox is checked jquery 
Javascript :: radio button onchange jquery 
Javascript :: how to store objects in localstorage 
Javascript :: Javascript get random item from array 
Javascript :: javascript appendchild image node 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =