zoukankan      html  css  js  c++  java
  • 汇编语言(王爽 第三版)实验十

    10_1显示字符串

    assume cs:code
    data segment
            db 'welcome to masm!',0
    data ends
    
    code segment
    start:  mov dh,8
            mov dl,3
            mov cl,2
            mov ax,data
            mov ds,ax
            mov si,0
            call show_str
            mov ax,4c00h
            int 21h
    show_str:       push dx
                    push cx
                    push si
                    mov di,0
                    mov bl,dh
                    dec bl
                    mov al,160
                    mul bl
                    mov bx,ax
                    add dl,dl
                    add bl,dl
            mov ax,0b800h
            mov es,ax
            mov al,cl
             s:     mov ch,0
                    mov cl,ds:[si]
                    jcxz ok
                    mov es:[bx+di],cl
                    mov es:[bx+di+1],al
            add di,2
            inc si
                    loop s
             ok:    pop dx
                    pop cx
                    pop si
                    ret
    code ends
    end start
               
                    

    10_2解决除法溢出的问题

    assume cs:code,ss:stack
    
    stack segment
            dw 8 dup (0)
    stack ends
    
    code segment
    start:  mov ax,stack
            mov ss,ax
            mov sp,16
            mov ax,4240h
            mov dx,00fh
            mov cx,0ah
            call divdw
            mov ax,4c00h
            int 21h
    
    divdw:  push ax
            mov ax,dx
            mov dx,0
            div cx
    
            mov bx,ax
            pop ax
            div cx
            mov cx,dx
            mov dx,bx
            ret
    code ends
    end start

    10_3数值显示

    assume cs:code
    
    data segment
            db 10 dup (0)
    data ends
    
    stack segment
        dw 8 dup(0)
    stack ends
    
    code segment
    start:  mov ax,42243
        mov bx,data
        mov ds,bx
        mov bx,stack
        mov ss,bx
        mov sp,10h
        mov si,0
        call dtoc
    
        mov dh,8
            mov dl,3
            mov cl,2
            call show_str
            mov ax,4c00h
            int 21h
    
    dtoc:    push ax
        push bx
        push si
        mov bx,10
        mov si,0
        
      s0:    mov dx,0
        div bx
        add dx,30h
        push dx
        mov cx,ax
        inc si
        inc cx
        loop s0
        
        mov cx,si
        mov si,0
      s1:    pop ds:[si]
        inc si
        loop s1
    
           pop si
        pop bx
        pop ax
        ret
        
    
    show_str:   push ax
            push dx
                    push cx
                    push si
                    mov di,0
                    mov bl,dh
                    dec bl
                    mov al,160
                    mul bl
                    mov bx,ax
                    add dl,dl
                    add bl,dl
            mov ax,0b800h
            mov es,ax
            mov al,cl
             s:     mov ch,0
                    mov cl,ds:[si]
                    jcxz ok
                    mov es:[bx+di],cl
                    mov es:[bx+di+1],al
            add di,2
            inc si
                    loop s
             ok:    pop si
                    pop cx
                    pop dx
            pop ax
                    ret
    code ends
    end start
              
  • 相关阅读:
    ES6语法:var、let、const的区别详解
    idea新建springboot项目
    Serlvet之cookie和session学习
    常见排序算法
    Spring MVC拦截器学习
    分组数据
    redis数据库学习
    redis实现排行榜
    redis整合springboot的helloworld
    dubbo整合springboot最详细入门教程
  • 原文地址:https://www.cnblogs.com/monster-prince/p/5543486.html
Copyright © 2011-2022 走看看