Sort hex numbers largest to smallest using Marie assembly language

604 Views Asked by At

sorting hex numbers largest to smallest i started by taking my first value and storing it into my increment variable so i can know my position throughout the code. I than take that increment variable(a)e and add one to it. this changes my position to the next value( a--> b) and store it in a temp (b) variable. than i compare the last position to new position by subtracting the new position. if the old position is greater than the new position (a>b) we continue on. i clear out whatever is in the accumulator. next i load up my size variable subtract one from it and if size is equal 0 it skips jump newnum and halts when it goes to newnum i add one to the increment variable(inc) making it now equal a new position (b--> c) an jump back to the top an add one to temp variable (c-->d ) and redo the whole process. im running into an error with it not halting.

/sort 

org 100 /starting line
Load  a /first variable 
Store inc /put num into array/ac

comp, load inc /jump to move to next num
Add one    /going next vari
Store temp / holding that value
Clear
Load inc /compareing the two num  
Subt temp  /a-b
store place
Skipcond 800 /if a>0 
Clear /ac is cleared out
/this will stop the loop because we only have 10 element
Load size /10
Subt one /10-1
Store size
Skipcond 400 / if size=0
Jump newnum
Halt
newnum,Load inc /ensure increment
Add  one
Store inc
Jump comp / takes us to the comparison

/num to sort 5, 35, 75, 45, 85, 25, 95, 55, 15, 65

size, hex 10 
temp, hex 0 /holding variable 
inc, hex 110 /increment variable
one, hex 1
place, hex 0 /holding variable 
/ numbers to sort
a, hex 5
b, hex 35
c, hex 75
d, hex 45
e, hex 85
f, hex 25
g, hex 95
h, hex 55
i, hex 15
j, hex 65
         ````
0

There are 0 best solutions below