如何在x86 32位架构中读取文件(使用系统调用中存储在缓冲区中)的十六进制值

发布于 2025-01-21 16:38:10 字数 1142 浏览 1 评论 0原文

让我们说一些文件“ 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文