top of page

Lab6 Part B

Updated: Nov 6, 2018

For the second part of this lab we were to choose an open source project and inspect the assembler language inside the package, whether it be inline or in a file. I have chosen the package "Amule", let us begin taking a closer look


Q: How much assembley-language code is present

There are 2 functions of assembler present in a file

#if defined(__GNUC__) && defined(__i386__)

static inline uint32_t

rol(uint32_t x, int n)

{

__asm__("roll %%cl,%0"

:"=r" (x)

:"0" (x),"c" (n));

return x;

}

#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )


#if defined(__GNUC__) && defined(__i386__)

static inline uint32_t

ror(uint32_t x, int n)

{

__asm__("rorl %%cl,%0"

:"=r" (x)

:"0" (x),"c" (n));

return x;

}

#define ror(x,n) ( ((x) >> (n)) | ((x) << (32-(n))) )


Q: Is the assembly code in its own file (.s or .S) or inline

The assembler is inline, located inside of a header file.

Q: Which platform(s) the assembler is used on

The code is looking for i386 which appears to be an AMD 32 bit processor type.

Q: What happens on other platforms

No real platform type specifications which I can see.

Q: Why it is there (what it does)


The commands rorl and roll look to be Rotate Left trough Carry and Rotate Right trough Carry. Each one of these commands shifts the bits one place to either the right or left.

I am not sure what this code is doing inside the program, I understand that sometimes on lower processors it will be more efficient to use bitwise operations like this opposed to a slower division or multiplication command, which can increase the speed of the program.

Q: Your opinion of the value of the assembler code, especially when contrasted with the loss of portability and increase in complexity of the code.


I believe assembler code is a very niche market for optimization, it has its place but due to the fact that it is not portable in addition to it being highly low level and with modern compilers doing a lot of behind the scenes optimization which was the primary focus of assembler in the past I would conclude that assembler is less useful today than it was in the past and therefore only those who have the technical skills and passion to work with assembler should venture out to attempt to use it. But having a basic understanding of assembler should still be part of every software programmers knowledge.

15 views0 comments

Recent Posts

See All

Closing Thoughts

For my final blog post I would like to discuss what I have learned and plan to utilize in the future from this course. So although I was not able to successfully improve my package to operate function

Stage 3 Optimization(COMPUTER ARCHITECTURE ENDIANESS)

Seeing as how the compiler flags did not provide any optimization I will on to my next attempt which is converting big endian to small endian. The aarch64 architecture uses the little endian byte orde

Stage 3 Optimization(Compiler Flags)

My first attempt to optimize the project will be to work with the compiler flag options. By default the compiler is set to compile in this manner "gcc -E -g -o2" The -E option represents preprocesses

bottom of page