Returns the absolute value of two numbers.

Source: Internet
Author: User

Datas segment <br/>; enter the data segment code here <br/> buff DW 198,217, '</P> <br/> dat dB, '</P> <br/> datas ends <br/> stacks segment <br/>; enter the stack segment Code <br/> stacks ends <br/> codes segment <br/> assume Cs: Codes, DS: datas, SS: stacks </P> <p> main proc far <br/> Start: <br/> push ds </P> <p> mov ax, datas <br/> mov ds, ax <br/>; enter the code snippet here <br/> call abs_value </P> <p> mov Cl, 10 <br/> Div Cl <br/> mov dat, Al <br/> mov DAT + 1, Ah <br/> Add dat, 48 <br/> Add DAT + 1,48 </P> <p> mov ah, 09 h; Display output <br/> mov dx, offset dat <br/> int 21 h </P> <p> mov ah, 4ch <br/> int 21 h </P> <p> main endp <br/> abs_value proc near <br/>; push ax <br/> push CX <br/> push Si <br/> mov Si, offset buff <br/> mov ax, [Si] <br/> Add Si, 2 <br/> CMP ax, [Si] <br/> jge next;> = 0 <br/> sub [Si], ax <br/> mov ax, [Si] <br/> JMP next2; <0 <br/> next: <br/> sub ax, [Si] <br/> next2: <br/> pop Si <br/> pop CX <br/>; pop ax <br/> RET <br/> abs_value endp </P> <p> codes ends <br/> end 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.