flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > ultimate xor use

Author
Thread Post new topic Reply to topic
Ali.Z



Joined: 08 Jan 2018
Posts: 732
Ali.Z 26 Jul 2018, 16:45
Code:
; standard and basic xor encryption
BASE = 2525h

_xor:
mov edx,BASE
xor edx,25h ; just any number to encrypt
; result is 2500h
; now to retrieve the encrypted number back
; xor base by result
xor edx,BASE ; remember edx have 2500h from last xor operation
; now edx have the original number which is 25h    


Code:
; another use of xor i dont know what to call it but it can be useful to store qword values and write them later to memory location
LOW_QWORD = 0ABCDEF10h
HIGH_QWORD = 23456789h
; FULL_QWORD = 23456789ABCDEF10h

_label:
mov edx,LOW_QWORD ; store the low 32bit value
xor edx,HIGH_QWORD ; we need the result
; result is 88888899h ; the KEY
mov eax,88888899h ; store it in eax for later use

; now to get the HIGH_QWORD, xor KEY by LOW_QWORD
xor edx,LOW_QWORD ; remember edx have 88888899h and being xored by ABCDEF10 which is low qword
; the result is 23456789h = high qword

; to get the LOW_QWORD xor KEY by the HIGH_QWORD
xor edx,eax ; = eax is our key 88888899h, edx = high qword
; result is 0ABCDEF10 = low qword    

_________________
Asm For Wise Humans
Post 26 Jul 2018, 16:45
View user's profile Send private message Reply with quote
MacroZ



Joined: 12 Oct 2018
Posts: 30
MacroZ 20 Oct 2018, 18:49
It can be used to flip bits
Code:
xor al,1 ; Flips the first bit    


Can we get another unique xor usage/trick by the next person? We want this thread to grow larger with unique answers. Forum users are encouraged to participate!

_________________
The king auto-generates two things to degrade dangerous artists and intellectuals. The King reserves the right to be king and has made the culprits in advance. Half of the time or more, they are auto-generated.
Post 20 Oct 2018, 18:49
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 20 Dec 2018, 12:03
MacroZ wrote:
It can be used to flip bits...

This is true. Nice find!
Code:
mov eax,1011b
; eax now is 1011b
xor eax,1000b
; eax now is 0011b
xor eax,1000b
; eax now is 1011b
xor eax,0001b
; eax now is 1010b
ret
    


Thank you!
Post 20 Dec 2018, 12:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.