Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Can someone tell me how to solve this exercise?

Sebas

New Coder
Code:
Write the bubblesort in ASM.

[CODE=c]// B must be stored at location 0x1000
int N = 10;
uint16_t B[N] = {0x1234, 0x3245, 0x6587, 0x0001, 0xffff, 0x4587, 0x3469, 0x6794, 0x1111, 0x8888};

int swap = 1;
N--;
while (swap) {
    swap = 0;
    for (int i = 0; i < N; i++) {
        if (B > B[i+1]) {
            int tmp = B;
            B = B[i+1];
            B[i+1] = B;
            swap = 1;
        }
    }
    N--;
}
[/CODE]
 
Code:
Write the bubblesort in ASM.

[CODE=c]// B must be stored at location 0x1000
int N = 10;
uint16_t B[N] = {0x1234, 0x3245, 0x6587, 0x0001, 0xffff, 0x4587, 0x3469, 0x6794, 0x1111, 0x8888};

int swap = 1;
N--;
while (swap) {
    swap = 0;
    for (int i = 0; i < N; i++) {
        if (B > B[i+1]) {
            int tmp = B;
            B = B[i+1];
            B[i+1] = B;
            swap = 1;
        }
    }
    N--;
}
[/CODE]
Having been through this eternal question from the 360th pit of hades... I can tell you, if you are looking for a 1-1 comparison... there is none lol, for lack of better words. Rather than looking at the code, try moving 1 step backward, and pseudo coding the algo with comments, and go from there.
 
Seems you are required to write this code in assembly language ? Seems a strange exercise. What you can do is have the C compiler produce assembly code (using the -i flag, if I remember correctly) and take it from there. Not sure if all compilers still have this functionality though.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom