r/badcode •

[deleted by user]

[deleted] — view deleted post

0 Upvotes

21 comments sorted by

View all comments

3

u/binarycat64 Dec 24 '20

Hashing:

	section .text
	global hash
	;; rdi: addr
	;; rsi: len
	;; hash: rax
hash:   xor rcx, rcx
	xor rcx, rsi
	xor rax, rax
loop:	xor rdx, rdx
	xor rdx, rcx
	add rdx, rdi
	xor rax, [rdx]
	ror rax, 5
	loop loop
	ret

fun fact: all mov instructions can be replaced by a pair of xor instructions.

1

u/AutoModerator Dec 24 '20

It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

/u/binarycat64, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

You can find some examples in the reddit help documentation.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.