0% found this document useful (0 votes)
7 views6 pages

Intel 8086 Assembly Programs

The document contains a collection of 15 Intel 8086 assembly programs, each with detailed line-by-line comments. Programs include displaying text, reading and echoing characters, performing arithmetic operations, comparing numbers, and converting character cases. Each program is structured with a small memory model and utilizes DOS interrupts for input and output operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views6 pages

Intel 8086 Assembly Programs

The document contains a collection of 15 Intel 8086 assembly programs, each with detailed line-by-line comments. Programs include displaying text, reading and echoing characters, performing arithmetic operations, comparing numbers, and converting character cases. Each program is structured with a small memory model and utilizes DOS interrupts for input and output operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

# ================================================

INTEL 8086 ASSEMBLY PROGRAMS

WITH LINE-BY-LINE COMMENTS (15 PROGRAMS)

# ================================================

-------------------------------------------------------------------

Program 1 — Print “HELLO” to Screen

Description:

Displays the text 'HELLO' using DOS interrupt 21h.

--------------------------------------------------------------------

.model small ; COMMENT: use small memory model

.stack 100h ; COMMENT: allocate 256 bytes stack

.data

msg db 'HELLO$' ; COMMENT: string terminated with '$' for INT 21h/09h

.code

main proc

mov ax, @data ; COMMENT: load data segment address

mov ds, ax ; COMMENT: initialize DS

mov dx, offset msg ; COMMENT: DX = address of string


mov ah, 09h ; COMMENT: DOS print-string function

int 21h ; COMMENT: display string on screen

mov ah, 4Ch ; COMMENT: terminate program

int 21h

main endp

end main

--------------------------------------------------------------------

Program 2 — Input a Character and Echo It

Description:

Reads one character and prints it back.

--------------------------------------------------------------------

.model small

.stack 100h

.code

main proc

mov ah, 01h ; COMMENT: DOS read-character

int 21h ; COMMENT: character returned in AL

mov dl, al ; COMMENT: move char to DL for printing

mov ah, 02h ; COMMENT: DOS print-character

int 21h
mov ah, 4Ch ; COMMENT: exit program

int 21h

main endp

end main

--------------------------------------------------------------------

Program 3 — Add Two 8-bit Numbers

Description:

Adds variables 'a' and 'b' and stores result in 'sum'.

--------------------------------------------------------------------

.model small

.stack 100h

.data

a db 12h ; COMMENT: first number

b db 34h ; COMMENT: second number

sum db ? ; COMMENT: result placeholder

.code

main proc

mov ax, @data

mov ds, ax ; COMMENT: set DS

mov al, a ; COMMENT: load first number


add al, b ; COMMENT: add second number

mov sum, al ; COMMENT: store result

mov ah, 4Ch ; COMMENT: exit

int 21h

main endp

end main

-------------------------------------------------------------------

Program 4 — Compare Two Numbers

Description:

Compares two numbers and branches accordingly.

-------------------------------------------------------------------

mov al, 25 ; COMMENT: first number

mov bl, 30 ; COMMENT: second number

cmp al, bl ; COMMENT: compare AL - BL

jg greater ; COMMENT: AL > BL

jl smaller ; COMMENT: AL < BL

je equal ; COMMENT: AL = BL

greater:

; COMMENT: code for greater


smaller:

; COMMENT: code for smaller

equal:

; COMMENT: code for equal

------------------------------------------------------------------

Program 5 — Convert Lowercase Letter to Uppercase

------------------------------------------------------------------

.model small

.stack 100h

.code

main proc

mov ah, 01h ; COMMENT: read single character

int 21h ; COMMENT: AL = input

sub al, 20h ; COMMENT: convert lowercase → uppercase

mov dl, al ; COMMENT: character to print

mov ah, 02h

int 21h

mov ah, 4Ch ; COMMENT: exit

int 21h

main endp
end main

-------------------------------------------------------------

Program 6 — Print Digits 0–9

-------------------------------------------------------------

mov cx, 10 ; COMMENT: loop counter (10 digits)

mov dl, '0' ; COMMENT: ASCII '0'

print_loop:

mov ah, 02h ; COMMENT: print character

int 21h

inc dl ; COMMENT: next ASCII digit

loop print_loop ; COMMENT: repeat until CX=0

------------------------------------------------------------

You might also like