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
; Display string subroutine, near description subroutine and main program in the same Code snippet (now no main program calls)
MOV ah,09h 9th number Function call: Display string
INT 21H; finish output display
Ret
Dispchs ENDP
Code ENDS; End of snippet
End START;
; Copy the above code into a text program such as Notepad and save it. (e.g. Helloch.asm)
; Compiling: MASM helloch.asm
; Connection: Link helloch.obj
; implementation: Helloch.exe
======================================================
Title ***hello,world the string input output by lluct***
Data segment, defining segments
Input db dup (?)
Define the input string, the string must be defined in db with a length of 100 bytes
MSG1 db ' Hello, ', ' $ '
; Define the output prefix string information, the string must be defined with DB, $ is the end sign (24h)
MSG2 db ', Welcome to here! ', ' $ '
; Define the output suffix string information
Headmsg db ' Please INPUT YOUR NAME: ', ' $ '
; string information to begin displaying
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
mov si,0; variable address register set initial value 0
Call enter; Invoke show carriage return newline subroutine
Lea Dx,headmsg; offset address of the string that the output starts to display
Call Dispchs; invoke display string subroutine
Repeat:mov ah,01h
Define the repeat label, which is used to loop through a single character. Call 1th: Enter a character from the keyboard and echo back
int 21h; complete input echo
CMP AL,0DH; input character and Cr (carriage return) comparison
Je exit, if equal to return, transfer to exit
MOV input[si],al; transfer the value of Al to the SI address of input (like this)