Pages

Sunday, January 17, 2016

Unconditional Jumps

Write a program that demonstrate unconditional Jumps

Program/Code:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
org 100h
mov AX, 35
JMP YES
NO:
MOV AH, 2
INT 21H
JMP EXIT_
YES:
MOV DL, 'A'
JMP NO
EXIT_:
ret
; Always Print: A

Convert capital alphabet to small and small to capital alphabet

Write a program that convert capital alphabet to small and small to capital alphabet

Program/Code:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
org 100h
MOV AH, 1
INT 21H
add al,20h
mov ah, 2
mov dl, al ;take output a character ;and show it by dl
int 21h

mov dl, 0Dh
int 21h
mov dl, 0Ah
int 21h


mov ah, 1
int 21h
sub al,20h
mov ah, 2
mov dl, al ;take output a character ;and show it by dl
int 21h
ret

Output/Result:




Simple output of string

Write a program that display output on screen

Program/Code:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
Org 100h
.data
Str db 'hello!', 0ah, 0dh,'$'
Str2 db 48h, 45h,4ch, 4ch, 4fh,0Ah, 0Dh, ' abcd$', 24h
 ;$ is use for terminate string
 ;0ah is use for new line feed
 ;0dh is use for carriage return / start line  
.code
Mov ah, 9
Lea dx, str
int 21h
Mov ah, 9
Lea dx, str2
Int 21h
ret

Output/Result:


Addition of two number by taking input and display output

Write a program that takes two number by user input and display output

Program/Code:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
org 100h
mov ah, 1
int 21h
 ;take input a character
 ;and store it in al
mov bl, al
int 21h ;take input a character
 ;and store it in al
sub al, 30h
sub bl, 30h
add al, bl
mov ah, 2
add al, 30h
mov dl, al ;take output a character
 ;and show it by dl
int 21h
ret
;Output 437 first two is input by user third one is output

Simple Define Double Word Addition

Write a program that take three variable and sum the first two variable and store its value in third one variable

Program/Code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
org 100h
.data
A dd 0x12345678
B dd 0x87654321
C dd 0
.code
mov ax, A+0
add ax, B+0
mov bx, A+2
adc bx, B+2
mov c+0, ax
mov c+2, bx
ret

Wednesday, January 13, 2016

Write a program that make a triangle

Program/Code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
org 100h
mov Cx, 5
mov Bx, 0
outer:
mov Bx, Cx
mov Ah, 2
mov Dl, '*'
line_print:
int 21h
Loop line_print
mov dl, 0AH
int 21h
mov dl, 0DH
int 21h
mov Cx, Bx
Loop outer
ret

OR

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
org 100h
mov Cx, 5
mov Bx, 0
outer:
mov Bx, Cx
mov Ah, 2
mov Dl, '*'
line_print:
int 21h
Loop line_print
mov dl, 0AH
int 21h
mov dl, 0DH
int 21h
mov Cx, Bx
Loop outer
ret

Output:


*****
****
***
**
*

C Language

Assembly Language





Assalam O Alikum 
Dear Programmer Here is some code in Assembly Language 8086. These program are complied by emu8086 emulator easily download by given link. I hope these program guide you learn Assembly Language.

Write a program that print A 5 times in output by loop


Program/Code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
mov Bx, 5
mov ah, 2
mov dl,'A'
loopLabel:
int 21h
sub Bx, 1
Cmp Bx, 0
JNE LoopLabel

Output:
AAAAA

Print * 5 times in output by loop keyword

Program/Code:

1
2
3
4
5
6
mov Cx, 5
mov Ah, 2
Label:
mov dl, '*'
int 21h
loop label

Output:
*****