Tuesday, 28 July 2015

Write a program to (a) prompt the user, (b) read first, middle, and last initials of a person's name, and (c) display them down the left margin In Assembly Language Using Function/Procedure.


Write a program to (a) prompt the user, (b) read first, middle, and
last initials of a person's name, and (c) display them down the
left margin.
Sample execution:
ENTER THREE INITIALS: JFK
J
F
K
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
TAG: EASY SOLUTION , 8086 MICROPROCESSOR, ASSEMBLY LANGUAGE CHAPTER 4 , PROGRAMMING EXERCISE ,
FUNCTION/PROCEDURE ,ASSEMBLY LANGUAGE PROGRAMMING AND ORGANIZATION OF THE IBM PC - CHAPTER 4 .

Solution:

.MODEL SMALL
.STACK 100H
.DATA
    STR DB 'ENTER THRRE INITIALS: $'
    STR1 DB '',0AH,0DH
    FIRST DB ? 
    STR2 DB '',0AH,0DH
    SECOND DB ?
    STR3 DB '',0AH,0DH
    THIRD DB ?
    STR4 DB '$'
.CODE
MAIN PROC
    
    MOV AX,@DATA
    MOV DS,AX

    CALL MSG_PROMPT_FUNC
    CALL INPUT_FUNC
    CALL OUTPUT_FUNC
    MOV AH,4CH
    INT 21H
    
    MAIN ENDP

MSG_PROMPT_FUNC PROC
    
    MOV AH,9
    LEA DX,STR
    INT 21H
    RET
    
    MSG_PROMPT_FUNC ENDP 

INPUT_FUNC PROC
    
    MOV AH,1
    INT 21H
    MOV FIRST,AL
    INT 21H
    MOV SECOND,AL
    INT 21H
    MOV THIRD,AL
    RET
    
    INPUT_FUNC ENDP

OUTPUT_FUNC PROC
    
    MOV AH,9
    LEA DX,STR1
    INT 21H
    RET
    
    OUTPUT_FUNC ENDP

END MAIN

No comments:

Post a Comment