assembly - x64 汇编语言中的轮换
问题描述
以下是我的指示。有点挣扎,不知道该怎么办。。
您的程序应该首先调用 ReadString (IO.cpp) 以获取一些合理长度的消息。接下来,调用 PROC 执行加密,将结果保存在新的内存位置。调用 DisplayMemory 在屏幕上显示加密值。还显示(但不需要加密)ReadString 返回的标记值。调用 DisplayNewline。然后,调用一个 PROC 来解密您的加密消息(通过将每个字节中的所有位向左旋转 3 个位置)。最后,调用 DisplayString 以显示您的解密消息。它应该与用户输入的字符串匹配。
这是一些示例输出(第一行由用户输入):
now is the time for all good men
73 7b bb 01 4b 9b 01 a3 43 2b 01 a3 4b 6b 2b 01 33 7b 93 01 0b 63 63 01 3b 7b 7b 23 01 6b 2b 73 00
now is the time for all good men
到目前为止,这是我的代码:
extrn ExitProcess: PROTO
extrn DisplayString: PROTO
extrn ReadString: PROTO
.data?
string1 byte 40 dup(?)
string2 byte ?
.code
Rotate PROC
mov rax, 0 ;counter = 0
Loop1:
cmp rax, rdx ;counter is less than string1 length
jge Done ;exit loop once string is processed
mov al, byte ptr[rcx + rax]
ror al, 3
mov byte ptr[rcx + rax], al
inc rax
jmp Loop1
Done:
mov byte ptr[r8 + rax], 0
mov rax, r8
ret ;return
Rotate ENDP
main PROC
push rbp ;save non-volatile
mov rbp, rsp ;make frame pointer for stack
sub rsp, 32 ;reserve shadow space
lea rcx, string1
call ReadString
call Rotate
sub eax, 1
mov edx, eax
lea rcx, string2
mov rcx, rax
call DisplayString
add rsp, 32 ;restore shadows space
pop rbp ;save non-volatile stack
xor rcx, rcx ;return code
call ExitProcess ;windows exit
main ENDP
END
解决方案
推荐阅读
- python - 如何使用 boto3 在同一存储桶(不同前缀)中下载和上传 s3 对象
- git - 如何使用 git 分支模式?
- android - 试用期结束后,所有 Google Play 订阅都将获得退款
- html - 如何在odoo报告中添加一个字段?
- server-side-rendering - 向服务器端呈现的应用程序提供端点 URI
- python - 如何将变量传递给另一个模块中的另一个函数
- javascript - 创建了一个没有错误的弹出模式,但它没有显示图像/描述
- c# - Asp.Net Core 2.1 获取请求不通过
- python-3.x - 在类中创建 AsyncHTTPClient 对象会导致 FileNotFound 错误
- vector - 有没有办法在 Rust 中从 1 开始索引向量?