-
Notifications
You must be signed in to change notification settings - Fork 12
[Command suggestion] Copypasta #96
Description
Command Syntax: (e.g. stonks [register]) copypasta [register, memory or immediate]
Command Description: implements the entirety of the memcpy libc function in a number of bytes that would fit in a general-purpose register
Which x86_64 Assembly instruction(s) would be used to translate this command?
mov [value], %rcx
jrcxz 1f
rep movsb (%rsi), (%rdi)
1: ...
What could this command be useful for?
Yes
What Meme is your command based on? (You can also provide a link to e.g. its KnowYourMeme page)
https://knowyourmeme.com/memes/copypasta
Notes:
Yes I use GAS syntax, sue me.
You could also implement this using speculative fetching and SSE if you're trying to squeeze every ounce of speed out of this, but I think it's funnier to be able to write "mov memcpy, %rax" and not lose any code in the process of executing that instruction
Also, this project is glorious, just needed to say that
EDIT: in case it's not clear, this command would copy [register, memory or immediate] bytes from the location stored in the source/RSI register to the location stored in the destination/RDI register. And yes, assuming the alignment is right the code assembles to 8 bytes in an object file (I've tested it). If one is concerned with returning the value as does the C function, sadly, the added move to the A register brings the total to 11 bytes...but anyway.