SPO600 Lab 7 Inline Assembler Lab

Hi all, I was assigned to work in my lab for my SPO600 class. Here is the outline of the specifications:

1. Write a version of the Volume Scaling solution from the Algorithm Selection Lab for AArch64 that uses the SQDMULH or SQRDMULH instructions via inline assembler. Test the performance of your solution and compare it to your previous solution(s).

Here is the code structure:

  1. Get data into vector register
    • ld1 {v.8h}, [sample register holding pointer]
  2. Get scaling factor into vector register or SIMD scalar register
    • dup v1.8h, [some register holding volumn]
  3. Scaling using SQDMULH
    • SQDMULH v0.8h, v0.8h, h1
  4. Store data back to array
    • st1 {v0.8h}, [sample register holding pointer] #16

We added an “Int16_t volint” and calculate it by using ” volint = volume * 32767;”

We added these asm snippet to our program:

__asm__ ( "ld1 : {v0.8h} x2, dup : v1.8h, x2 SQDMULH : v0.8h, v0.8h, h1, st1 {v0.8h}, x2 #16 ",
 : //empty output
 : "r"(x), "r"(volint) //input


2.Find the assembler in that software, and determine:

  • How much assembly-language code is present, which platform(s) it is used on, why it is there (what it does)
    • The program I look at is SooperLooper , SooperLooper is a live looping sampler capable of immediate loop recording, overdubbing, multiplying, reversing and more. It allows for multiple simultaneous multi-channel loops limited only by your computer’s available memory.
    • the asm code is used in a file name atomic.h. It contains Load and Store instructions and the atomic operation execution which is guaranteed to be complete before interrupt handler executes.
    • the platform that the atomic.h file is executed on is x86_64, here is the snippet of the code.

* atomic_add - add integer to atomic variable
* @i: integer value to add
* @v: pointer of type atomic_t
* Atomically adds @i to @v. Note that the guaranteed useful range
* of an atomic_t is only 24 bits.
static __inline__ void atomic_add(int i, atomic_t *v)
__asm__ __volatile__(
SMP_LOCK "addl %1,%0"
:"=m" (v->counter)
:"ir" (i), "m" (v->counter));

  • Your opinion of the value of the assembler code VS the loss of portability/increase in complexity of the code.
    • The atomic operation is a very powerful feature when it comes to working with multiple threads. Because the program has to wait for a specific thread to be completed done before performing the other thread. This will helps eliminated the possibility of deadlock in the program.





Author: dannydat2005

Hello, Welcome to my blog site on programming and related development topics. At this point in time I’m relatively new to the professional developer world, but am getting my foothold into the arena. I’ve benefited greatly already by the contributions and documentation that others have provided on the web for jobs that have been asked of me, and this shall represent the beginnings of my contributions in return. My interests in programming that you may find topics on within this site include open source development.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s