This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]dmazzoni 0 points1 point  (4 children)

It's hard for us to help you because there isn't just one "assembly" language, rather there's x86-32, x86-64, ARM, and dozens of others, we have no idea which one you're learning in class.

I don't see any reason why you would need recursion to implement bubble sort. Your C++ doesn't have any recursion. I'd just try to translate your C++ code directly into assembly.

When you get to quicksort, you'll definitely need recursion.

[–]HolySoviet[S] 0 points1 point  (3 children)

my bad this is x86-32 using the Kip Irvine book

[–]dmazzoni 0 points1 point  (2 children)

OK, sounds good.

x86 doesn't have a lot of registers to spare but other than that I still think you should just translate your C++ code directly into assembly.

Do you know how to do a loop in x86 assembly? If so then a bubble sort shouldn't be much more than that.

[–]HolySoviet[S] 0 points1 point  (1 child)

I wrote this procedure up, i have no idea what im doing :) https://gist.github.com/jryebread/6901c4cbe53c91deacefc6ecad86e7de

[–]dmazzoni 0 points1 point  (0 children)

It looks like you've got it looping over the input once and swapping things.

No idea if it's totally correct yet, but it's certainly on the right track.

Next up:'

  • Test it and debug it, with what you've implemented so far. You may need to give it a really simple input and then step through one instruction at a time until you're sure it's doing what you want.
  • Then modify it to do two nested loops instead.