x86_64 assembly (System V ABI, GNU assembler), using the C standard library for printf.
coffee.S:
.global coffee .text coffee: push %rbp mov %rsp, %rbp mov $prices, %rsi xor %eax, %eax #offset mov $4, %ecx loop: movlpd (%rsi, %rax, 8), %xmm1 cmpeqsd %xmm0, %xmm1 sub $8, %rsp movlpd %xmm1, (%rsp) pop %rdx cmp $0, %rdx jne goodjob inc %rax loop loop mov $badfmt, %rdi xor %eax, %eax end: call printf pop %rbp ret goodjob: mov $goodfmt, %rdi mov $names, %rsi mov (%rsi, %rax, 8), %rsi mov $1, %eax jmp end .section .rodata prices: .double 2.20 .double 2.30 .double 2.40 .double 3.50 names: .quad first .quad second .quad third .quad fourth first: .asciz "Americano" second: .asciz "Latte" third: .asciz "Flat white" fourth: .asciz "Filter" goodfmt: .asciz "Here is your %s, have a nice day!\n" badfmt: .asciz "Sorry, exact change only, try again tomorrow!\n"
coffee.h:
void coffee(double d);
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), using the C standard library for printf.
coffee.S:
coffee.h: