【发布时间】:2021-06-24 17:43:39
【问题描述】:
我想将 Dword 向下转换为字节,以便我可以将其存储到 call WriteToFile 可读文本的文本文件中。我该怎么做?
.386
.model flat, stdcall
INCLUDE Irvine32.inc
.stack 4096
.Data
total DWORD ? ;total is a variable which holding a math calc output
totalTXT BYTE ? ;totalTXT would be the output in String value.
这是我尝试降低转化率的地方
xor eax, eax
mov eax, total
mov totalTXT, al
我需要以字节为单位的 totalTXT,以便我可以将文本作为文本存储到文件中。但是调试后,我的文本文件变空了。
WRITE_TO_FILE: ;assume file is successfully opened
mov eax,fileHandle
mov edx, OFFSET totalTXT
mov ecx, LENGTHOF totalTXT
call WriteToFile
call CloseFile
【问题讨论】:
-
那应该写入一个字节,即您从
total加载的二进制整数的低字节。 (未转换为 ASCII 或任何内容,但文件大小应为 1,而不是 0)。但无论如何,How do I print an integer in Assembly Level Programming without printf from the c library? 解释了如何将整数转换为 ASCII 十进制字符串。
标签: assembly masm irvine32 masm32