forked from miguelmota/x86-assembly-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencode_string.asm
executable file
·71 lines (53 loc) · 1.03 KB
/
encode_string.asm
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
; Description: Encodes a string.
INCLUDE Irvine32.inc
.data
key BYTE -2, 4, 1, 0, -3, 5, 2, -4, -4, 6
keySize = $ - key
encodedMsg BYTE "ENCODED:",0dh,0ah,0
plainText BYTE "This is a secret message.",0
.code
main PROC
call Clrscr
mov esi, OFFSET plainText
L1: mov ecx, keySize
mov edi, OFFSET key
call Encode
jnz L1
mov esi, OFFSET plainText
mov edx, OFFSET encodedMsg
call WriteString
mov edx, OFFSET plainText
call WriteString
call Crlf
call Crlf
exit
main ENDP
Encode PROC
L1: push ecx
cmp BYTE PTR[esi], 0
je L4
mov cl, [edi]
cmp cl,0
jge L2
rol BYTE PTR[esi],cl
jmp L3
L2: ror BYTE PTR[esi], cl
L3: inc esi
inc edi
pop ecx
loop L1
or eax, 1
jmp L5
L4: pop ecx
L5: ret
Encode ENDP
END main
; =======================================
; OUTPUT
; =======================================
COMMENT !
ENCODED:
§å┤s♦K▄☻▬Ç▄V▒r¼╓V═▄▬│e┼
Press any key to continue . . .
!
; =======================================