Simple Assembly Language Programs:

How to display the string in assembly (Simple “Hello World” Message )?

.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
main endp 
end  main                                    ;end of program

 

(a)How to add two registers in Assembly Language?

.MODEL SMALL
.STACK 100H

.code

main proc

Mov AL,04H

Mov BL,05H

ADD AL,BL

Mov DL,AL

Mov ah,2

int 21h

MAIN ENDP
END MAIN

(b)How to add two registers in Assembly Language (USING SUB )? 

.

.MODEL SMALL
.STACK 100H

.DATA

MSG1 DB ‘ENTER FIRST NUMBER: $’
MSG2 DB ‘ENTER SECOND NUMBER: $’
MSG3 DB ‘ADDITION RESULT IS: $’

.CODE
MAIN PROC

MOV AX,@DATA
MOV DS,AX

LEA DX,MSG1
MOV AH,9
INT 21H

MOV AH,1
INT 21H

MOV BL,AL

LEA DX,G2
MOV AH,9
INT 21H

MOV AH,1
INT 21H

MOV CL,AL

LEA DX,G3
MOV AH,9
INT 21H

SUB BL,30H
SUB CL,30H

ADD CL,BL
ADD CL,30H

MOV DL,CL
MOV AH,2
INT 21H

MOV AH,4CH
INT 21H

MAIN ENDP
END MAIN

 

One Reply to “Simple Assembly Language Programs:”

  1. Aw, this was a really nice post. In concept I wish to put in writing like this additionally ?taking time and actual effort to make a very good article?however what can I say?I procrastinate alot and under no circumstances seem to get one thing done.

Leave a Reply

Your email address will not be published. Required fields are marked *