Showing posts with label print. Show all posts
Showing posts with label print. Show all posts

Print String in Assembly Language


Program to print a string in Assembly Language is given below:

;program to print a string in Assembly Language
.model small
.stack
.data
str db "Hello World!",'$'
.code
mov ax, seg str
mov ds, ax
mov ah,09
lea dx,str
int 21h

EXIT:
mov ah,4ch
int 21h
end

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Carriage Return, (ASCII 13D) is the control character to bring the cursor to the start of a line.



Line-feed (ASCII 10D) is the control character that brings the cursor down to the next line on the screen.

(We use the abbreviations CR and LF to refer to Return and Line-feed in comments.)


;How to come to new line while printing in assembly language.
.model small
.stack
.data
str db "First Line",0AH,"SECOND LINE",0AH,"3RD line",'$'
.code
MOV AX,@DATA
MOV DS,AX
MOV AH,09
MOV DX, OFFSET STR
INT 21H

mov ah,4ch
int 21h
end


Alternate way of printing Hello World in Assembly Language

Lower-case to Upper-case in Assembly Language Program

Program to convert lower-case to upper-case in Assembly Language.



TITLE Write Assembly program to Input Lower Case letter from user and display it’s upper case. (Subtract 32 in ASCII)

.model small
.stack

.code

;Input character
mov ah,07h;
int 21h;

;Capitalize
sub al,32

;print character
mov ah,02h;
mov dl,al;
int 21h;

;Give control back to OS
mov ah,4ch
int 21h

end


You might be interested in

Upper-Case to Lower-Case in Assembly Language Program

Print character in assembly language



Program to print a character in assembly language is given below.
Write character to standard output. DL = character to write, after
execution AL = DL.

TITLE Print character in assembly language

.model small
.stack

.code
mov dl,'A';
mov ah,02h;
int 21h;

mov ah,4ch;
int 21h;

end