如何在x86 32位架构中读取文件(使用系统调用中存储在缓冲区中)的十六进制值
让我们说一些文件“ file.txt”具有
56
21
f6
ad
上述文件中的内容时,当我从文件中读取它们时,将它们的内容存储在以下代码中的缓冲“ ARR”中 现在,当我尝试从缓冲区“ arr”中读取存储为char的值时,应该可以预期。 有什么办法可以直接在缓冲区中阅读十六进制值?
我的目的是读取5为5(基本10),读取6为6(基本10),读取2为2(基本10),读取1 AS 1(基数10),读取f AS 15(基数10),阅读6 AS 6(基本10),读取A为10(基本10),读为1(基数10) 。有什么方法可以做吗?
%include "io.mac"
.DATA
File_name db "file.txt",0
.UDATA
file_pointer resd 1
arr resb 4
.CODE
.STARTUP
mov EAX,5 ;opening the file "file.txt"
mov EBX,File_name
mov ECX,0
mov EDX,0o777
int 0x80
mov [file_pointer],EAX
mov EAX,3 ;reading from the file "file.txt"
mov EBX,[file_pointer]
mov ECX,arr
mov EDX,4
int 0x80
.END
Let us say some file "file.txt" has the contents
56
21
f6
ad
the contents of the above file are in hexadecimal when i am reading them from the file and stored them in a buffer "arr" in the below code
Now when I try to read from the buffer "arr" the values stored as char which should be expected.
Is there any way I can read hexadecimal values directly in the buffer?
my intention is to read 5 as 5(base 10) ,read 6 as 6(base 10) ,read 2 as 2(base 10) ,read 1 as 1(base 10) ,read f as 15(base 10) ,read 6
as 6(base 10) ,read a as 10(base 10) ,read d as 14(base 10) one by one
. Is there any way to do that?
%include "io.mac"
.DATA
File_name db "file.txt",0
.UDATA
file_pointer resd 1
arr resb 4
.CODE
.STARTUP
mov EAX,5 ;opening the file "file.txt"
mov EBX,File_name
mov ECX,0
mov EDX,0o777
int 0x80
mov [file_pointer],EAX
mov EAX,3 ;reading from the file "file.txt"
mov EBX,[file_pointer]
mov ECX,arr
mov EDX,4
int 0x80
.END
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论