我已经编写了一个代码,该代码应该生成某种数字列表,但是即使我为它们分配了初始值,我的数据段变量也没有被初始化?
This is how DS:0000
looks when I run it:
这是我的代码,但数据段只保留垃圾值:
MODEL small
STACK 100h
DATA SEGMENT
size1 dw 0000h
arr dw 20 dup(0000h)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
sidra_rekursivit proc
mov bp, sp
xor ax, ax
mov ax, [bp+2]
; tnai azira
cmp ax, 1
je azira
; tempo
mov cx, ax ; save ax
shr ax, 1
jnc zugi ; if zugi
izugi: ; else
mov ax, cx
;multiply by 3
shl ax, 1
add ax, cx
;end multiply
; add 1
inc ax
push ax
call sidra_rekursivit
jmp azira
zugi:
push ax
call sidra_rekursivit
azira:
; put the numbers in arr
mov bx, [size1] ; arr size
xor dx, dx ; clear dx
mov dx, [bp+2] ; take the number from the stack
mov word ptr arr[bx], dx ; put the number in the arr
inc size1 ; increase the array posiotion
ret 2
sidra_rekursivit endp
start:
;input
mov ah, 1
int 21h
mov ah, 0
sub al, 48
mov dh, 10d
mul dh
mov dl, al
mov ah, 1
int 21h
mov ah, 0
sub al, 48
add dl, al
; function call: stack push
; push input
xor dh, dh
push dx
call sidra_rekursivit
exit:
mov ax, 4c00h
int 21h
CODE ENDS
END start
你知道如何解决吗?