NASM 阵列用户输入

NASM Array User input

提问人:SB Chegg 提问时间:11/8/2023 更新时间:11/8/2023 访问量:6

问:

部分 .data num1 dd 10, 20, 30, 40, 50, 10, 20, 30, 40, 50 msg dd “值=%d”,10,0

部分 .text 外部_printf 全球_main

_主要: 推送 EBP MOV EBP,ESP 移动EAX,10 mov ebx,num1 ;p oint bx 到第一个数字 mov ecx,0 ;负载 0

loop:

;store the value because external function like printf modify the value
push ebx
push eax
push ecx

;print the value stored on stack
    push DWORD [ebx]
push msg
    call _printf
;clear the stack
add esp,8

;restore thses values
pop ecx
pop eax
pop ebx
;increment the counter
inc ecx
;add 4 byte to ebx
add ebx,4
;compare value stored in ecx and eax
cmp ecx,eax
jne loop

    
;destroy the stack
    mov esp,ebp
    pop ebp

    ret

我想从上面的代码中编写一个类似的 NASM 代码,但数字应该来自用户输入,并且应该询问用户是否要输入多少个数字。

阵列 NASM

评论


答: 暂无答案