Categories
- 4th semester (27)
- 5th semester (3)
- ADA (13)
- Assembly Level Language (12)
- BE (45)
- C Language Programming (5)
- C language (20)
- C++ Language (5)
- CCP Lab programing (3)
- Computer Programming Lab (3)
- DAA Lab Programming (13)
- Data Structure and C++ laboratory Program (6)
- Data Structure and C++ labotary Program (5)
- Design and Analysis of algorithm (14)
- First Year (5)
- MASM (12)
- Microprocessor (12)
- Microprocessor lab program (12)
- System Software & OS Laboratory (5)
- Unix program (4)
- bachelor of engineering (30)
- basic (1)
- basic mathematics (2)
- beginners (10)
- c++ program (9)
- calculations (7)
- computer science (30)
- downloadable (5)
- engineering syllabus (4)
- simple program (6)
Trend Posts
Blogger news
Author
Followers
Blog Archive
-
▼
2014
(37)
-
▼
February
(12)
- a program to create a file (input file) and to del...
- Read a pair of input co-ordinates in BCD and move ...
- Write a program to simulate a Decimal Up-counter t...
- Read the current time from the system and display ...
- Compute nCr using recursive procedure. Assume that...
- Read your name from the keyboard and display it at...
- Read two strings, store them in locations STR1 and...
- Reverse a given string and check whether it is a p...
- Read an alphanumeric character and display its equ...
- Sort a given set of ‘n’ numbers in ascending order...
- Write two ALP modules stored in two different file...
- Search a key element in a list of ‘n’ 16-bit numbe...
-
▼
February
(12)
Friday, February 21, 2014
ASSUME
DS: DATA,
CS: CODE
DATA SEGMENT ;
start of data segment
LIST
DB
12H,10H,04H,08H ; n
(4) number of elements stored in a LIST array
COUNT
DB 03H ; n-1
counter value stored in COUNT variable
DATA
ENDS ;
end
of data segment
CODE
SEGMENT ;
start
of code segment
START : MOV
AX, DATA ;
initializing the data segment
MOV DS, AX
XOR AX, AX ; clear
AX register content
MOV CL, COUNT ; store n-1 value (3) in CL register (outer loop count)
BACK2: MOV SI, OFFSET
LIST ; set the pointer to the 1st
location of LIST array
MOV BL, CL ; temporally
store the n-1 value in BL register (inner loop count)
BACK1: MOV AL, [SI] ;
get the 1st array element, ie. LIST [0]
to AL
INC SI ;
increment
the pointer by 1 to point to the next location
; ie: LIST[SI+1]
CMP AL, [SI] ; compare
AL with LIST[SI+1]
JB NEXT ;
if 1st
element is less than 2nd element then go to NEXT to
;
decrement the
inner loop count value in BL, to indicate one
;
comparison is
over.
XCHG [SI],
AL ; otherwise swap
the numbers.
MOV [SI-1],
AL
NEXT:
DEC BL ;
decrement
inner loop count value.
JNZ BACK1 ; if inner loop count value is not 0, then go to
BACK1 to
;
repeat the
comparison of remaining elements of LIST array.
LOOP BACK2 ; decrement the outer loop count
value in CL register
; (perform n-1 passes)
MOV AH, 4CH ;
terminate the program
INT 21H
CODE ENDS ;
end
of code segment
END
START
Output:
D:\MASM>
Masm 3a.asm;
D:\MASM>
Link 3a.obj;
D:\MASM>
TD 3a.exe
Then
press F7 to trace the program (line
by line execution).
Click on View
menu and select Dump to see the
output.
Subscribe to:
Post Comments (Atom)
2 comments:
Too gud
before the loop back2 command, there must be command to decrement CL
Post a Comment
You are very Important to Us...
STAY TUNE...