----------------------------------
排序
负数显示补侍芦袭胡码如-1显老禅带示65535
如想增加数据只需在a变量中添加,
同时长度len要相应的更改
----------------------------------
data segment
len dw 10
a dw -1,2,100,-100,99,-120,15,46,411,102
b dw 0
data ends
code segment
main proc far
assume cs:code,ds:data
start:
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
mov cx,len
dec cx
loop1:
mov di,cx
mov bx,0
loop2:
mov ax,a[bx]
cmp a[bx+2],ax
jge cotinue
xchg ax,a[bx+2]
mov a[bx],ax
cotinue:
add bx,2
loop loop2
mov cx,di
loop loop1
mov si,0
loop3:
mov bx,a[si]
call bini
call crlf
add si,2
mov di,len
add di,len
cmp si,di
jl loop3
ret
main endp
bini proc near
mov cx,10000d
call bin
mov cx,1000d
call bin
mov cx,100d
call bin
mov cx,10d
call bin
mov cx,1d
call bin
ret
bini endp
bin proc near
mov ax,bx
mov dx,0
div cx
mov bx,dx
mov dl,al
add dl,30h
mov ah,02h
int 21h
ret
bin endp
crlf proc near
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
mov ah,02h
int 21
ret
crlf endp
code ends
end start
嘿嘿 用汇编语言完成y=n!计算也不是很难啊算法:
1 就是一个循环程序 初始条件:
循环次数=n定义一个变量SUM装结果 初始值SUM=1
2 循环体:裂岩 SUM=SUM*n
3 循环陵派结束控制:
每次循环后 循环次数减1 如果不等于0 则继续循环 执行步骤2(循环体)
否则结束
呵呵满意 就选满意回答喽肆汪御
data segment para str1 db ‘one’, ’$’ str2 db ‘Two’,’$’衫判稿 str3 db ‘Three’, ’$’ str4 db ‘four’,’$’str5 db ‘five’或孝,’$’ tab dw str1,str2,str3,str4,str5 data ends ssg segment stack dw 256 dup(?) ssg ends code segment para assume cs:code,ss:ssg,ds:data main proc far mov ax, data mov ds, ax mov ah, 1 键盘输入 int 21h callasc2bin mov bl, al mov bh, 0 decbx shlbx, 1 mov dx, tab[bx] mov ah, 9 int 21h mov ax, 4c00h Int 21h main endp 将冲颂ASCII转换为二进制数 入口:AL存放ASCII 出口:转换后数值在AL asc2bin proc sub al, 30h cmp al, 9 jbe next sub al, 7 next: ret asc2bin endp end main欢迎分享,转载请注明来源:内存溢出
评论列表(0条)