计算数组(Assembly,Irvine)中数字之间的差异

问题描述 投票:0回答:1

我正在尝试计算数字之间的差距。为此,我使用2个数组。因此,除了输出和数字后面出现的奇怪符号之外,其他所有东西都正常工作。

此刻数组中的第一个数字,元素之间的第二个差异,已经移动到第二个数组的3d-2nd。输出:1 2 2/3 44/722/9一个/2

此符号从哪里来?是什么原因造成的?注册错误?为什么在第一个循环中'gap'(array)具有正确的数字,但是当我稍后遍历此数组时,它只有2个和有线符号?

INCLUDE Irvine32.inc

.data
array byte 1,3,7,9
gap byte ?
blank byte ' '
ph byte "Done",0

.code
main PROC
        mov eax,0
        mov ecx,lengthof array  
        mov esi, offset array
        mov edi,offset gap
         arr:

         mov al,[esi]
         call writedec; here

         .if ecx==1
         mov edx,offset ph 
         call writestring
         .else
         mov al,blank
         call writechar

            mov al,[esi+1]
            sub al,[esi]

            call writedec; here

            mov [edi],al

            ;check block
            mov al,blank
            call writechar
            mov al,[edi] ; here
            call writedec
            mov al,blank
            call writechar

             inc esi
             inc edi        
           .endif

           mov al,'/'
         call writechar

         loop arr

        call crlf  

         mov eax,0
         mov ecx,lengthof gap
         mov esi,offset gap

         go:

         mov al,[esi]
         call writedec
         mov al,blank
         call writechar
         inc esi
         loop go

         exit

main ENDP



myexit proc

              call waitmsg
              ret
      myexit endp

end main

谢谢!

assembly irvine32
1个回答
0
投票

Gotcha!可变间隙错误初始化。

这是正确的初始化gap byte lengthof array-1 dup(?)

© www.soinside.com 2019 - 2024. All rights reserved.