汇编做的小程序无法运行 数组插入元素
数组插入元素DATAS SEGMENT
x dw ?
array_head dw 3,5,15,23,37,49,52,65,78,99
array_end dw 105
n dw 32
DATAS ENDS
CODES SEGMENT
main proc far
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
mov ax,datas
mov ds,ax
mov cx,11
call print
mov ax,n
mov x,0ffffh
mov si,0
compare:
cmp array_end[si],ax
jle insert
mov bx,array_end[si]
mov array_end[si+2],bx
sub si,2
jmp short compare
insert:
mov array_end[si+2],ax
mov cx,12
call print
ret
main endp
print proc near
pop cx
push ax
push dx
push si
mov si,0
again:
mov ax,array_head[si]
mov dl,10
div dl
add al,30h
add ah,30h
mov dh,ah
mov dl,al
mov ah,2
int 21h
mov al,dh
mov dl,al
mov ah,2
int 21h
mov dl,08h
mov ah,2
int 21h
add si,2
loop again
pop si
pop dx
pop ax
ret
print endp
CODES ENDS
END START