Experiment 10 writing subroutines 2. Solving the problem of division overflow

Source: Internet
Author: User
assume cs:code,ss:stackstack segment        dw 8 dup (0)stack endscode segmentstart:  mov ax,stack        mov ss,ax        mov sp,10h        mov ax,4240h        mov dx,0fh        mov cx,0ah        call divdw        mov ax,4c00h        int 21hdivdw: ;子程序定义开始        push ax ;进栈,说明后边要用到。低16位先保存        mov ax,dx ;ax这时候的值是高16位        mov dx,0 ;dx置0是为了不影响下边余数位,使得被除数的高16位为0        div cx ;H/N        mov bx,ax ;ax,bx的值为商,即(int)H/N;dx的值为余数,即(rem)H/N        pop ax ;ax此时的值为L,即低16位        div cx ;L/N。注意,16位除法的时候,默认被除数的高16位在dx中,低16位在ax中        mov cx,dx        mov dx,bx        ret ;子程序定义结束        code endsend start

Video Tutorials

Experiment 10 writing subroutines 2. Solving the problem of division overflow

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.