Sunday, 12 July 2015

Simple Function Call Program In Assembly Language.

/* Simple Function Call Program In Assembly Language. */

/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/

Solution:

.MODEL SMALL
.STACK 100H
.DATA
    STR1 DB 0AH,0DH,'SECOND STATEMENT. $'
    STR2 DB 'FIRST STATEMENT. $'

.CODE

MAIN PROC
 
    MOV AX,@DATA
    MOV DS,AX
 
    CALL FUNC
 
    MOV AH,9       ;
    LEA DX,STR1    ;this will be executed last
    INT 21H        ;
 
    MOV AH,4CH
    INT 21H
    MAIN ENDP
FUNC PROC
 
    MOV AH,9        ;
    LEA DX,STR2     ;this will be executed first
    INT 21H         ;
    RET
 
    FUNC ENDP

END MAIN

No comments:

Post a Comment