"Hello,world" Advanced Assembler Series

Source: Internet
Author: User
Tags exit first string

Selection branch of TITLE ***hello,world Advanced Program by lluct***

Data SEGMENT, defining segments

MSG1 DB ' ***welcome to Me program by lluct*** ', ' $ '

To define the first string information for the output, the string must be defined with DB, and $ is the end flag

MSG2 DB ' 1:basic message 2:advanced message ', ' $ '

; Define string information for output: Select Menu

MSG3 DB ' please CHOOSE: ', ' $ '

; Define string information for output: Select prefix

MSG4 DB ' hello,world! ^-^ ', ' $ '

; Define string information for output: information for branch 1

MSG5 DB ' This is my asm_86 program! @^-^@','$'

; Define string information for output: information for branch 2

ErrMsg DB ' CHOOSE error! -_-b ', ' $ '

; Define string information for output: Error message Selection

Data ENDS end of segment

Code SEGMENT, defining snippets

Assume Cs:code; the content of CS

Assume Ds:data; the content of the DS

Start:mov Ax,data; program starting from Start

MOV Ds,ax;D S-Value, section address of data

Call ENTER; invoke show carriage return newline subroutine

LEA DX,MSG1; Output the offset address of the first string

Call Dispchs; invoke display string subroutine

Call ENTER; invoke show carriage return newline subroutine

Call ENTER; Ditto AH-^

LEA dx,msg2; Output the offset address of the second string

Call Dispchs; invoke display string subroutine

Again:call ENTER; define AGAIN label. Used to select the error loop

LEA dx,msg3; Output the offset address of the third string

Call Dispchs; invoke display string subroutine

MOV ah,01h; Call 1th function: Enter a character from the keyboard and Echo

INT 21H; complete input echo

CMP AL, ' 1 '; input characters compared to 1

JE BASICP if equal, transfer to BASICP label (je=jump if Equal)

CMP AL, ' 2 '; input characters and 2-phase comparison | |

JE ADVANP if equal, transferred to ADVANP label (je= if equal to transfer)

JMP error, otherwise unconditionally transferred to the error label

Exit:mov ah,4ch 4C Function call: Terminates the current program and returns the calling program

INT 21H; back to Dos

Basicp:call ENTER; What, also want to explain AH. Halo-_-!!!

LEA dx,msg4; Output the offset address of the third string

Call Dispchs; invoke display string subroutine

Call ENTER; .....

JMP exit, unconditional transfer to exit label

Advanp:call ENTER; 55555555

LEA Dx,msg5, explained four times, should understand

Call Dispchs; invoke display string subroutine

Call ENTER; I'll die for you.

JMP exit, unconditional transfer to exit label

Error:call ENTER

LEA dx,errmsg; Output selection error message

Call Dispchs; invoke display string subroutine

MOV dl,07h; output ASCII alarm (Bell) control character Bel (07H)

Call dispch; calls display a single word subcode program

Call ENTER

JMP AGAIN

DISPCH PROC NEAR

Display a single character subcode program that near the subroutine and the main program in the same Code snippet (now no main program calls)

MOV ah,02h 2nd number function call: Display output characters

INT 21H; finish output display

To return to a RET;

DISPCH ENDP; end of subroutine

Enter PROC NEAR; show carriage return newline subroutine

MOV DL,0DH; return controller CR (0DH) for output ASCII

Call dispch; calls display a single word subcode program

MOV dl,0ah; line break control for output ASCII LF (0AH)

Call dispch; calls display a single word subcode program

To return to a RET;

ENTER ENDP; subroutine end

Dispchs PROC NEAR

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.