x86_64 assembly (System V ABI, GNU assembler), for those concerned about speed.
change.S:
.global change .text change: push %rbx xor %edx, %edx xor %ecx, %ecx mov %edi, %eax mov $table, %r9 loop: mov (%r9, %rcx, 4), %ebx div %ebx mov %eax, (%rsi, %rcx, 4) mov %edx, %eax xor %edx, %edx inc %ecx cmp $4, %ecx jne loop pop %rbx ret .section .rodata table: .int 25 .int 10 .int 5 .int 1
change.h:
/* * coins[0] = number of 25 cent coins * coins[1] = number of 10 cent coins * coins[2] = number of 5 cent coins * coins[3] = number of 1 cent coins */ unsigned int change(unsigned int n, unsigned int coins[4]);
I am concerned about speed
we need to get that stuff off the streets smh
causin' good folk to think they need to write stuff in assembly, fcol >.>
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
x86_64 assembly (System V ABI, GNU assembler), for those concerned about speed.
change.S:
change.h:
I am concerned about speed
we need to get that stuff off the streets smh
causin' good folk to think they need to write stuff in assembly, fcol >.>