ZKX's LAB

用汇编语言计算1到n的累加 不用子程序写 该怎么编写 汇编语言计算累加和原理

2021-04-26知识5

用汇编语言计算1到n的累加 不用子程序写 该怎么编写 data segmentmsg db 'input N:$'data endscode segmentassume cs:code,ds:datamain proc nearstart:mov ax,datamov ds,axmov dx,offset msgmov ah,09hint 21hcall decibin;接收N的子程序mov cx,bxmov bx,0loop1:add bx,cx;1+2+…N的和存入BXloop loop1call crlfcall bini;显示BX中的内容mov ah,4chint 21hretmain endpdecibin proc near;接收N子程序mov bx,0newchar:mov ah,1int 21hsub al,30hjl exitcmp al,9djg exitcbwxchg ax,bxmov cx,10dmul cxxchg ax,bxadd bx,axjmp newcharexit:retdecibin endpbini proc near;转化为十进制输出子程序mov cx,10000dcall binmov cx,1000dcall binmov cx,100dcall binmov cx,10dcall binmov cx,1dcall binretbini endpbin proc nearmov ax,bxmov dx,0div cxmov bx,dxmov dl,aladd dl,30hmov ah,02hint 21hretbin endpcrlf proc near;回车换行子程序mov dl,0dhmov ah,02hint 21hmov dl,0ahmov ah,02hint 21hretcrlf endpcode endsend start

8086环境下的,用汇编语言求1到10累加和,要详细一点,谢谢 CODE SEGMENTASSUME CS:CODESTART:MOV AX,0MOV BX,1MOV CX,10AGAIN:ADD AX,BXINC BXLOOP AGAINMOV AH,4CHINT 21HCODE ENDSEND START

汇编语言怎么写1到100的累加和 DSEG DSEG SEGMENT RESULT DW?存放和 DSEG ENDS CSEG SEGMENT ASSUME CS:CSEG,DS:DSEG START:MOV AX,DSEG MOV DS,AX MOV AX,1;从1开始加 MOV RESULT,0;。

#汇编语言计算累加和原理

随机阅读

qrcode
访问手机版