当前位置:编程学习 > 汇编语言 >>

汇编语言1^3+2^3+3^3+4^3+5^3+6^3=?显示输出,跪求易做图修改程序、、、不胜感激

assume cs:code ds:data data segment sum1 db '1^3+2^3+3^3+4^3+5^3+6^3=','$' data ends code segment start: mov cx,6 mov di,0 mov dx,0 mov bx,0 mov ax,0 s: add bx,1 mov ax,bx mul ax,ax mov si,ax mul bx,si add ax,di mov di,ax loop s mov dx,offset sum1 mov ah,09h int 21h mov ah,4ch int 21h code ends end start
答案:DATA  SEGMENT
    SUM1  DB  '1^3 + 2^3 + 3^3 + 4^3 + 5^3 + 6^3 = '
    SUM2  DB  ?, ?, ?, ?, ?, '$'
DATA  ENDS

CODE  SEGMENT
    ASSUME  CS:CODE, DS:DATA
START:
    MOV  AX,  DATA
    MOV  DS,  AX
;-----------------------------
    MOV  BX, 0
    MOV  CX, 6
S:
    MOV  AX, 0
    MOV  AL, CL
    MUL  CL
    MUL  CL
    ADD  BX, AX
    LOOP  S
;-----------------------------
    MOV  AX, BX
    MOV  DI, OFFSET SUM2
    ADD  DI, 4
    MOV  BX, 10
    MOV  CX, 5
S1: CWD
    DIV  BX
    ADD  DL, 30H
    MOV  [DI], DL
    DEC  DI
    LOOP S1 
;-----------------------------
    MOV  DX, OFFSET  SUM1
    MOV  AH, 09H        
    INT  21H      
    MOV  AH, 4CH
    INT  21H
CODE  ENDS
    END  START

运行结果:
1^3+2^3+3^3+4^3+5^3+6^3=00441
其他:2 assume cs:code ds:data
data segment
sum1 db '1^3+2^3+3^3+4^3+5^3+6^3=','$'
data ends
code segment
start:	mov cx,6
	mov di,0
	mov dx,0
	mov bx,0
	mov ax,0
s:	add bx,1
	mov ax,bx
	mul ax,ax
	mov si,ax
	mul bx,si
	add ax,di
	mov di,ax
	loop s
	mov dx,offset sum1
               mov ah,09h      
   	int 21h   
	mov ah,4ch
      	int 21h
code ends
end start data ends
code segment
start:	mov ax,data
                 mov ds,ax

                mov dx,offset sum1
               mov ah,09h    
                int 21h
                mov cx,6
	mov di,0
	mov dx,0
	mov bx,0
	mov ax,0
s:	add bx,1
	mov ax,bx
	mul bx
        mul bx
	add di,ax
	loop s
        mov dx,0
        push dx
        mov ax,di
   c:   mov bx,10
        mov dx,0
        div bx
        add  dx,30h
        push dx
              
        cmp ax,0
        jnz c
dis:     pop dx
         cmp dx,0
         jz   e
         mov ah,2
        int 21h
         jmp dis

 e:      mov ah,0
   	int 16h   
	mov ah,4ch
      	int 21h
code ends
end start

上一个:汇编语言怎么能够在虚拟中发出声音
下一个:汇编程序是不是就是汇编语言编译器的意思?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,