Skip to content

Instantly share code, notes, and snippets.

@wridgers
Last active January 25, 2019 00:58
Show Gist options
  • Save wridgers/02c6cd5edf39e36151c52ca19eb96dcf to your computer and use it in GitHub Desktop.
Save wridgers/02c6cd5edf39e36151c52ca19eb96dcf to your computer and use it in GitHub Desktop.
; nasm -f elf64 yes.asm
; gcc -o yes yes.o
; ./yes | pv -a > /dev/null
global main
section .text
main:
mov rdi, 1
mov rsi, msg
mov rdx, msg.len
loop:
mov rax, 1
syscall
jmp loop
section .data
msg: times 16384 db "y",10
.len: equ $ - msg
// gcc -O3 -pipe -march=native -mtune=native yes.c -o yes
// ./yes | pv -a > /dev/null
#include <unistd.h>
#define LEN 1 << 15
int main() {
char str[LEN];
for (int i = 0; i < LEN; i += 2) {
str[i] = 'y';
str[i+1] = '\n';
}
while (write(1, str, LEN));
}
@wridgers
Copy link
Author

I fixed the asm version. Should work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment