Wang Shuang assembly language experiment 10 2. Numerical Display

Source: Internet
Author: User
Assume Cs: codedata segment dB 10 DUP (0) Data endscode segmentstart: mov ax, 13666 mov BX, data mov ds, BX mov Si, 0 call DTOC mov DH, 8 mov DL, 3 mov Cl, 2 call show_str mov ax, 4c00h int 21 h DTOC: Push dx push ds push Si push cx push ax push di mov Di, 0 mov BX, 10 mov Si, 0 pushnumber:; press data into the stack (otherwise the display order is reversed) mov dx, 0; DX must be assigned 0 each time; otherwise, the Division is incorrect Div BX add DL, 030 H push DX mov CX, ax Inc Si jcxz popnumber JMP short pushnumber popnumber: Pop DX mov DS: [di], DL Inc di dec Si mov CX, si jcxz ok1 JMP short popnumber ok1: Pop di pop ax pop CX pop Si pop DS pop dx ret show_str: push ax push BX push CX push DX push Si push di push es mov BL, DL; DX mov ax, 0b800h mov es, ax mov ax, 0 mov Al, DH mov Di, 050 H Mul di add Al, BL add ax, ax mov BX, ax; at this time, the DX value must be 0 mov Di, 0 mov ah, cl s: mov Al, DS: [Si]; assign values to the corresponding display cache, until the string contains 0 mov CX, 0 mov Cl, Al jcxz OK mov ES: [bx + DI], ax Inc Si add Di, 2 JMP short s OK: pop es pop di pop Si pop DX pop CX pop BX pop ax retcode endsend start

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.