【发布时间】:2012-01-08 07:26:42
【问题描述】:
大家好,我不确定我是否以正确的方式进行这一切。我需要斐波那契数列的前 12 个数字来计算我已经很确定它在做什么。但是现在我需要使用 dumpMem 在我的程序中显示 (Fibonacci) 的十六进制内容。我需要打印出:01 01 02 03 05 08 0D 15 22 37 59 90
但我只得到:01 01 00 00 00 00 00 00 00 00 00 00
非常感谢任何提示或帮助。
INCLUDE Irvine32.inc
.data
reg DWORD -1,1,0 ; Initializes a DOUBLEWORD array, giving it the values of -1, 1, and 0
array DWORD 48 DUP(?)
Fibonacci BYTE 1, 1, 10 DUP (?)
.code
main PROC
mov array, 1
mov esi,OFFSET array ; or should this be Fibonacci?
mov ecx,12
add esi, 4
L1:
mov edx, [reg]
mov ebx, [reg+4]
mov [reg+8], edx
add [reg+8], ebx ; Adds the value of the EBX and 'temp(8)' together and stores it as temp(8)
mov eax, [reg+8] ; Moves the value of 'temp(8)' into the EAX register
mov [esi], eax ; Moves the value of EAX into the offset of array
mov [reg], ebx ; Moves the value of the EBX register to 'temp(0)'
mov [reg+4], eax ; Moves the value of the EAX register to 'temp(4)
add esi, 4
; call DumpRegs
call WriteInt
loop L1
;mov ebx, offset array
;mov ecx, 12
;L2:
;mov eax, [esi]
;add esi, 4
;call WriteInt
;loop L2
;Below will show hexadecimal contents of string target-----------------
mov esi, OFFSET Fibonacci ; offset the variables
mov ebx,1 ; byte format
mov ecx, SIZEOF Fibonacci ; counter
call dumpMem
exit
main ENDP
END main
【问题讨论】:
-
你有没有写过任何尝试进行十六进制转换的东西?您显示的代码似乎纯粹与计算斐波那契数列有关,根本与十六进制转换无关。我怀疑有人会非常努力地帮助完成明显的家庭作业,直到/除非您自己尝试一些尝试并就您在其中遇到的问题提出具体问题。
-
@JerryCoffin dumpMem 负责将字节转换为十六进制,您需要做的就是传递正确的偏移量和长度。
-
@JerryCoffin:计算斐波那契数列。我现在需要显示偏移量的十六进制内容,这是我遇到问题的地方。 ;)
标签: loops assembly masm fibonacci irvine32