Skip to content

Commit

Permalink
#EDITS: broken dgemm implementation for x86 SSE2
Browse files Browse the repository at this point in the history
  • Loading branch information
akielaries committed Feb 27, 2024
1 parent 2131d54 commit 97926a0
Show file tree
Hide file tree
Showing 5 changed files with 4,718 additions and 36 deletions.
26 changes: 15 additions & 11 deletions experiment/test.S
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
.globl asm_function
asm_function:
// Assembly code to add two integers
// Parameters are passed in registers: a in %edi, b in %esi
// Result is stored in %eax
// Load a into %eax
mov %edi, %eax

// a + b + c - d - e + f + g - h
// Parameters are passed in registers: a in %rdi, b in %rsi
// Result is stored in %rax
// Load a into %rax
mov %rdi, %rax

// Add b to %eax
add %esi, %eax
// Add b to %rax
add %rsi, %rax

// Add c to %eax
add %edx, %eax
// Add c to %rax
add %rdx, %rax

// Subtract d from %eax
sub %ecx, %eax
// Subtract d from %rax
sub %rcx, %rax

// subtract e from %rax
sub %r8, %rax

ret // Return

13 changes: 10 additions & 3 deletions experiment/test.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#include <stdio.h>

// Declare the assembly function as an external function
extern int asm_function(int a, int b, int c, int d);
extern int asm_function(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, double l);

int add (int a, int b, int c) {
int d = 2;

return asm_function(a, b, c, d);
// performs:
//
// a + b + c - d - e + f + g - h + i - j + k

int d = 2, e = 11, f = 33, g = 22, h = 4, i = 39, j = 18, k = 9;

double l = 1.23;

return asm_function(a, b, c, d, e, f, g, h, i, j, k, l);
}

int main() {
Expand Down
Loading

0 comments on commit 97926a0

Please sign in to comment.