02_ Assembly Language (sub-program 01_ basic input and output function template)

Source: Internet
Author: User
Tags microsoft dynamics

Program Requirements:

The data contains a variable that writes an input method to enter a number NUM (0<=num<=65535) from the command line and outputs the number using the output method.

Objective:

Input function template

Output function template

Code implementation:

1 ;Example: Data contains a variable, write an input method to enter a number from the command line, output this number2Stack SEGMENT Stack'STACK'3STAK DW theDUP (?)4 STACK ENDS5 6 DATA SEGMENT7 NUM DW?8 DATA ENDS9 Ten CODE SEGMENT OneAssumeCS:CODE,DS:DATA,SS:STACK A MAIN PROC - START:  MOVAx,data -         MOVDs,ax the         XORAx,ax;Ax Reset 0 -         PagerINPUT -         PagerOUTPUT -         MOVah,4ch +         INT21H - MAIN ENDP +  AINPUT PROC;Inlet parameter: No Exit parameter: BX (therefore cannot exceed 65535) at         PUSHAX -         PUSHCX -         PUSHDX -         PUSHSI;Save Multiplier -         XORBX,BX -         XORcx,cx in         XORDX,DX -         MOVSI,Ten to NEXT:   MOVAH, on +         INT21H;receive the number of the keyboard -         CMPAl,0dh;determine if it is a carriage return the         JZDone;JZ: equals then jumps *         CMPAL,'0' $         JBERROR1;JB: Less then jumpPanax Notoginseng         CMPAL,'9' -         JAERROR1;JA: Greater than the jump the         SUBal,30h;converts ASCII characters into corresponding numbers +         MOVCl,al A         MOVAX,BX the         MULSI +         ADDax,cx -         MOVBx,ax $         JMPNEXT;continue to receive next data $ ERROR1: MOVBX,0FFFFH -         JMPEXIT - Done :   MOVdl,0ah the         MOVAH, Geneva -         INT21H;Output EnterWuyi         MOVDL,0DH the         MOVAH, Geneva -         INT21H Wu EXIT:   POPSI -         POPDX About         POPCX $         POPAX -         RET        ;subroutine returns - INPUT ENDP -  AOUTPUT PROC near;Inlet parameter: BX exit parameter: None +         PUSHAx;Protection Registers the         PUSHBX -         PUSHCX $         PUSHDX the         PUSHSI the         MOVSI,Ten    ;The si is the divisor the         XORcx,cx the         MOVAx,bx;inlet parameters in BX - NEXT1:  MOVDx0    ;DX Storage Remainder, clear 0 in         DIVSI;Ax and DX consist of 32 bits divided by 16 bits of SI, the quotient is saved in Microsoft Dynamics AX, the remainder is saved in DX the         PUSHDX the         INCCX;CX++,CX How many bits are recorded? About         CMPAx0 the         jnzNEXT1;JNZ does not equal the jump the OUTP:   POPDx;remainder out of stack the         ADDdl,30h +         MOVAH,2 -         INT21H the LOOP OUTPBayi         POPSI;Recovery Register the         POPDX the         POPCX -         POPBX -         POPAX the         RET        ;subroutine returns the OUTPUT ENDP the CODE ENDS theEND START

02_ Assembly Language (sub-program 01_ basic input and output function template)

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.