Wednesday, September 19, 2012

Message Print in Assembly Language

TITLE PRINTING HABIJABI

.MODEL SMALL    

.STACK 100H   

.DATA
MSG  DB 'Take Input: $'
MSG1 DB 'First Value: $'
MSG2 DB 'Second Value: $'
A    DB 5
B    DB ?

MAIN PROC
; initializing data segment  
    MOV AX, @DATA
    MOV DS, AX  ; initialized :D 
    
; display message
    LEA DX, MSG
    MOV AH, 9  ; message print function
    INT 21h  
    
; input 
    MOV AH, 1
    INT 21h
    MOV B, AL
    
; new line
    MOV AH, 2
    MOV DL, 0DH
    INT 21H
    MOV DL, 0AH
    INT 21H   
    
; display message1
    LEA DX, MSG1
    MOV AH, 9  ; message print function
    INT 21h
    
; display A
    MOV AH, 2
    MOV DL, A
    INT 21h
    
; new line
    MOV AH, 2
    MOV DL, 0DH
    INT 21H
    MOV DL, 0AH
    INT 21H   
    
; display message2
    LEA DX, MSG2
    MOV AH, 9  ; message print function
    INT 21h
    
; display B 
    MOV AH, 2
    MOV DL, B
    INT 21h
    
; return to DOS

    MOV AH, 4CH
    INT 21h
    
MAIN ENDP
    END MAIN

No comments:

Post a Comment

Thanks - Jajabor, 2014