【发布时间】:2018-05-26 13:37:57
【问题描述】:
我的程序应该将二进制文件编码为 base 64。 在 EOF 之前一切正常。我无法在输出字符串的末尾添加“=”。
只有在读取最后一个字节时才会发生这种情况。它应该填补空白。这是我在必须添加一两个“=”时检测的代码。
Read:
mov eax,3 ; Specify sys_read call
mov ebx,0 ; Specify File Descriptor 0: Standard Input
mov ecx,Bytes ; Pass offset of the buffer to read to
mov edx,BYTESLEN ; Pass number of bytes to read at one pass
int 80h ; Call sys_read to fill the buffer
mov ebp,eax ; Save # of bytes read from file for later
cmp rax,1 ; If EAX=0, sys_read reached EOF on stdin
je MissingTwoByte ; Jump If Equal (to 1, from compare)
cmp rax,2 ; If EAX=0, sys_read reached EOF on stdin
je MissingOneByte ; Jump If Equal (to 2, from compare)
cmp eax,0 ; If EAX=0, sys_read reached EOF on stdin
je Done ; Jump If Equal (to 0, from compare)
所以在我的 :MissingOneByte 和 :MissingTwoByte 函数中,我应该将我的 '=' 添加到 Bytes 中,对吗?我怎样才能做到这一点?
【问题讨论】:
-
不清楚您的问题是什么。您确定不是在寻找
mov [Bytes+1], '='之类的吗? -
不,我真的不知道怎么解释,我的英语不太好。
-
这是 32 位还是 64 位?
-
它在 Linux 64 位上!
-
您的代码使用 32 位
int 0x80,因此如果您继续将其构建为 64b 二进制文件,您可能(并且很可能将)遇到问题:@987654321 @(例如,您的二进制文件肯定不能在 Windows10 linux“子系统”中运行,打包的 Ubuntu 仅支持 64b,不支持int 0x80,而使用控制台 stdin/stdout 的正确 64b 二进制文件可以)跨度>
标签: linux assembly x86 64-bit nasm