Assembly 我创建了一个dd数组,但可以';我什么也不输出

Assembly 我创建了一个dd数组,但可以';我什么也不输出,assembly,operating-system,x86,bios,Assembly,Operating System,X86,Bios,我想在预定义的数组中找到最大的数字,并将其输出到屏幕上。现在我知道了一个事实,我找到最大数字的逻辑是正确的,但输出它就像打一场永远不会结束的战争 segment .data matrix dd 1,62,3,44,35, \ 61,52,43,45,55, \ 17,23,37,74,65, \ 13,12,93,94,95, \ 31,21,13,14,25 \ segment .

我想在预定义的数组中找到最大的数字,并将其输出到屏幕上。现在我知道了一个事实,我找到最大数字的逻辑是正确的,但输出它就像打一场永远不会结束的战争

segment .data


   matrix dd   1,62,3,44,35, \
            61,52,43,45,55, \
            17,23,37,74,65, \
            13,12,93,94,95, \
            31,21,13,14,25 \


segment .bss

holder  resb    4

counter resb    4


segment .text

global _start

_start:

    mov eax, matrix
    call big

big:
    mov esi, holder
    mov edi, counter
    mov edi, 0
    jmp switch

loop:
    inc edi
    cmp esi, [eax + edi]
    jg switch
    cmp edi, 25 
    jle loop
    mov eax, [esi]
    add eax, '0'

    mov eax, 4 ; after some advice from a few forum member i tried the [ebx + ecx *4] but no luck 
    mov ebx, 1 
    mov ecx, eax
    mov edx 
    mov eax, [ebx + ecx * 4]

    int 0x80


switch:
    mov esi, [eax + edi]
    jmp loop


exit:
    mov eax, 1
    xor ebx, ebx
    int 0x80

我知道这不能回答您的问题,但我想您可能想知道如何以更有效的方式在列表中查找最大的数字:

mov     esi, matrix       ; esi now points to the beginning of the matrix
xor     ebx, ebx          ; ebx will mold the max
xor     ecx, ecx          ; ecx is the counter

loop:
  cmp   ecx, 25           ; Make sure the end of the matrix has not been reached
  jge   end_loop          ; If the end has been reached, jump out of the loop

  mov   eax, [esi+ecx*4]  ; Read the next DWORD from the matrix
  cmp   ebx, eax          ; Compare it to ebx (the current max)
  jle   skip              ; If it's not greater than the current max, skip it
  mov   ebx, eax          ; Otherwise, update ebx with the new max

  skip:
  add   ecx, 1            ; incriment the counter
jmp     loop              ; Loop to the end of the matrix

end_loop:

; ebx now contains the max value in the 25 number matrix

能告诉我们您使用的平台和操作系统吗?打印输出是你能想象到的最特定于平台的事情之一。@KerrekSB哇,这很有趣我不知道我以为这是通用语言,我使用linux和nasm编译器进行汇编它怎么可能是通用的?您可以在汇编程序中编写“裸”机器代码(例如引导加载程序),也可以在其中编写“托管程序”,其任何和所有细节都取决于操作系统。。。在托管环境中,您通常希望调用一些适当的系统调用。无论如何,“Linux”是这里的重要信息。干杯。我认为重要的信息是我使用nasmHm的事实,也许,但不是这样。这只是告诉我们您需要哪种方言的源代码。但重要的问题是如何使字符出现在屏幕上,这是一个OS/BIOS问题:-)