我正在尝试编写一个非常简单的程序,它将列出一个名为array的字节中的值,然后反转数字。这就是给我的问题:
编写程序执行以下操作:使用BYTE指令定义学生ID号的9位数的列表,并将其命名为array。编写指令来颠倒数组中这些数字的顺序。
到目前为止,我得到的是:
.DATA
array BYTE 9h, 6h, 4h, 5h, 2h, 8h, 7h, 4h, 2h
.CODE
start:
mov esi, 0
mov edi, 0
; ?????
call DumpRegs
call WriteInt
exit
END start我使用一个字节来命名为九位数的数组。我不知道如何开始冲销过程。这是通过循环完成的吗?我理解这个简单的循环,但是我对这个完全不知所措。您所能提供的任何帮助或答案都非常感谢。提前感谢您帮我学习了这篇文章。
发布于 2014-03-13 10:00:52
这是我整理的一些东西,希望能有所帮助。
.DATA
array BYTE 9h, 6h, 4h, 5h, 2h, 8h, 7h, 4h, 2h
reversearray BYTE 9 DUP (0) ; assign storage for array that will contain reverse
.CODE
mov ecx, SIZEOF array ; length of array is 9, so ecx contains 9
lea esi, array ; address of the start of array
lea edi, reversearray ; address of the start of reversearray
decarray:
movzx eax, byte ptr [esi+ecx-1] ; byte from esi (array start) + ecx counter - 1
mov byte ptr [edi], al ; store byte we have in al, into reverse array (edi)
inc edi ; add 1 to reverse array location for next bytes storage when we loop again
loop decarray ; if ecx is 0 we end, otherwise loop again and ecx will now be ecx-1
; do other stuff here, print our arrays etchttps://stackoverflow.com/questions/22336569
复制相似问题