我正在开发一个使用.asm汇编语言的简单程序,该程序可以从用户读取10个整数,然后再次将其打印出来。当我打印数组时,前9个数字是不寻常的值,但最后一个数字可以正确打印。
segment .data
enterInt db "Enter 10 Integers",10,0
whichOrder db "Enter 1 for ascending order | Enter 2 for descending order",10,0
segment .bss
array_r resd 1000
segment .text
global asm_main
asm_main:
push ebp
mov ebp, esp
mov eax, enterInt
call print_string
mov eax, 0
mov ecx, 0
topofloop1:
call read_int
mov DWORD [ array_r + ecx * 1 ], eax
inc ecx
cmp ecx, 10
jne topofloop1
mov ecx, 0
topofploop1:
mov eax, DWORD [ array_r + ecx * 1 ]
call print_int
call print_nl
inc ecx
cmp ecx, 10
jne topofploop1
mov eax, 0
mov esp, ebp
pop ebp
ret