用汇编语言编这样一个程序,如图
展开全部
data segment
num1 db 12,-24,0,35,-15,30,-2, -8,10,9
num2 db 10 dup(0)
num3 db 10 dup(0)
data ends
code segment
assume cs:code, ds:data
start:
mov ax, data
mov ds, ax
lea si, num1
lea cx, num2
sub cx, si ; get num1's length
mov si, 0 ;index -> num1
mov bx, 0 ;index -> num2
mov di, 0 ;index -> num3
lopstart:
mov al, num1[si]
test al, 80H
jz _num2
mov num3[di], al
inc di
jmp _next
_num2:
mov num2[bx], al
inc bx
_next:
inc si
loop lopstart
;---print num2
mov cx, bx ;num2's length
lea si, num2 ;si->num2's address
_pnum2:
mov al, byte ptr [si]
call print
inc si
loop _pnum2
; print cr lf
mov ah,2
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h
;---print num3
mov cx, di ;num3's length
lea si, num3 ;si->num3's address
_pnum3:
mov al, byte ptr [si]
call print
inc si
loop _pnum3
;exit to dos
mov ah,4ch
int 21h
;print al with binary
print proc near
mov ah, 2
mov bl, al
mov cx, 8 ;8 bit
_p1:
rol bl, 1
mov dl, bl
and dl, 1
add dl, 30h
int 21h
loop _p1
mov dl, 20h
int 21h ; output a space
ret
print endp
code ends
end start
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询