Steven Wright
asked on
Transfer A bubble sort from C to 3 Assembly Languages.
Hey there guys.
I have been given a chunk of C++ Code that I need to turn into assembly for 3 Processors.
The, 6805, DS89C420 & ARM7
Below is the code.
Any Help would be amazing.
void BubbleSort (void) {
unsigned char tmp;
int i, j;
for (i=0; i<sizeof(Data)-1; i++) {
for (j=0; j<sizeof(Data)-1-i; j++) {
if (Data[j+1] < Data[j]) {
tmp = Data[j];
Data[j] = Data[j+1];
Data[j+1] = tmp;
}
}
}
}
I have been given a chunk of C++ Code that I need to turn into assembly for 3 Processors.
The, 6805, DS89C420 & ARM7
Below is the code.
Any Help would be amazing.
void BubbleSort (void) {
unsigned char tmp;
int i, j;
for (i=0; i<sizeof(Data)-1; i++) {
for (j=0; j<sizeof(Data)-1-i; j++) {
if (Data[j+1] < Data[j]) {
tmp = Data[j];
Data[j] = Data[j+1];
Data[j+1] = tmp;
}
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
it is for another processor but should give you the main principles of a conversion from c to assembler.
note, the sample code sorts dword type what is unsigned int. if you want to sort unsigned char you need code to copy from byte to dword and back.
note, most c/c++ compilers have an option to show disassembly. this may contain a flavour of assembly code which could not transferred 1:1 to your micro processors but generally gives you a valuable idea of how the code should look like.
Sara