# 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]

#### Sebas

##### New Coder
This may be easier to look at

#### Attachments

• 12.png
15.2 KB · Views: 3

#### Antero360

##### King Coder
Staff Team
Security Analyst
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.

#### cbreemer

##### King Coder
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.

Replies
0
Views
76
Replies
0
Views
310
Replies
5
Views
239
Replies
0
Views
359
Replies
4
Views
175