1

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
         ````
Erik Eidt
  • 23,049
  • 2
  • 29
  • 53
  • Try debugging it with the minimal list size (e.g. 0 if it can handle that or else 1). This will make debugging simpler. Single step through the whole thing to completion with the shortest test case element and verify that it can terminate with those smaller cases. Don't work on 10 elements until you have the shorter element counts working. – Erik Eidt Apr 13 '22 at 00:42
  • 1
    FYI, your counter is 16 but you only have 10 values, which you should see during debugging. Note: MARIE also supports a DEC data directive as an alternative to HEX. – Erik Eidt Apr 13 '22 at 00:49

0 Answers0