summaryrefslogtreecommitdiffstats
path: root/yes.asm
blob: 1a7b5d8ae4ae03084523d9529eb18730f1012b1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
; Version	: 0.1
; Last update	: 12/8/2020
; Description	: Do you need ultimate yes performance? Well, you've come to the right place.
; Copyright (C) ; 2020 Gentoo-libre Install
; Licence	: GPLv3+
; Note		: Assumes that the stack is at least 65536 bytes.

section .data
Yes:	db 0xA,'y',0xA,'y',0xA,'y',0xA,'y'	;8 bytes as the stack is written to 8 bytes at a time

section .text
	global _start

_start:
xor ecx,ecx	;0 out the counter register

ALIGN 16	;Align the stack to 16 bytes
;; rsp is pointing to the "start" of the stack
yees: inc ecx	;increment the counter every loop

push qword[Yes]	;push 8 bytes to the stack

test ecx,512	;Check for 8192 loops
je yees		;continue if amount is not reached

;;the stack is now full of 32768 bytes of '\ny' (maybe a bit more, but that's ignored)
mov edi,1	;fd = STDOUT_FILENO
mov edx,4096	;print 65536 bytes
mov rsi,rsp	;the value of rsp is the start of where the text is
yes:
mov eax,1	;sys_write
syscall

jmp yes		;print those 65536 bytes of 'y\n' forever

;;this won't ever be reached but it's left for any future usage
exit:
mov eax, 60 ;sys_exit
xor edi, edi ;return 0
syscall ;do sys_exit