You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DATA SEGMENT
NUM1 DB 9H
NUM2 DB 7H
ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
MOV AL,NUM1
MOV BL,NUM2
XCHG AL,NUM2
XCHG BL,NUM1
MOV AH,4CH
INT 21H
ENDS
END START
Assembly program for print "Hello World"
.model small ;defines the memory model to be used for the ALP
.data ;data segment begins here
msg db 10d,13d,"Hello World$" ;String Hello World gets stored in msg
.code ;code segment begins here
mov ax,@data ;moving base address of data to ax
mov ds,ax ;moving contents of ax into ds
;data section now gets initialized
lea dx,msg ;load the offset address of msg
mov ah,09h ;to display contents at dx
int 21h ;call the kernel
mov ah,4ch ;to terminate the program
int 21h ;call the kernel
end ;end of program
Assembly program for taking an input and show the output
.model small
.stack 100h
.data
buff db 26 ;MAX NUMBER OF CHARACTERS ALLOWED (25).
db ? ;NUMBER OF CHARACTERS ENTERED BY USER.
db 26 dup(0) ;CHARACTERS ENTERED BY USER.
.code
main:
mov ax, @data
mov ds, ax
;CAPTURE STRING FROM KEYBOARD.
mov ah, 0Ah ;SERVICE TO CAPTURE STRING FROM KEYBOARD.
mov dx, offset buff
int 21h
;CHANGE CHR(13) BY '$'.
mov si, offset buff + 1 ;NUMBER OF CHARACTERS ENTERED.
mov cl, [ si ] ;MOVE LENGTH TO CL.
mov ch, 0 ;CLEAR CH TO USE CX.
inc cx ;TO REACH CHR(13).
add si, cx ;NOW SI POINTS TO CHR(13).
mov al, '$'
mov [ si ], al ;REPLACE CHR(13) BY '$'.
;DISPLAY STRING.
mov ah, 9 ;SERVICE TO DISPLAY STRING.
mov dx, offset buff + 2 ;MUST END WITH '$'.
int 21h
mov ah, 4ch
int 21h
end main