Assignment Help, Cloud Based ERP System, Microsoft NAV Certification
WELCOME !!

Please Register, ask for assignment solutions & post the solutions if you know any.

LETS START POSTING YOUR IDEAS AND THOUGHTS AND BUILD THE COMMUNITY OF EXPERTS.

Assignment Help, Cloud Based ERP System, Microsoft NAV Certification

Stock Market, Online Tutoring, Cloud Based ERP System, Microsoft Dynamics Reporting, Microsoft Nav Certification


You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Sorting by insertion method on 5th March 2009, 12:17 am

wap to sort 5 numbers in array in ascending order.


Wap to sort 5 numbers in array in ascending order.


TITLE INSERTION SORTING
Code:

.MODEL SMALL
.STACK 64H
.DATA
NUM DB 45,32,12,89,01
.CODE
PROCESS PROC
   CMP AL,NUM[ST+1]    ;COMPARES IF FIRST DATA IS SMALLER
   JL GO         ;AND IF SO JUMPS TO GO LABEL OTHERWISE
   XCHG AL,NUM[SI+1]    ;SWAP MEMORY CONTENT TO REGISTER
   MOV NUM[SI],AL      ;PUT SMALLER ONE TO FIRST MEMORY   
   MOV AH,1      ;SET FLAG
GO:   INC SI         ;IF NOT INCREASE SI BY 1
   RET         
PROCESS ENDP

MAIN PROC
   MOV AX,@DATA      ;LOAD BASE ADDRESS(BA) OF DATA SEGMENT
   MOV DS,AX      ;MOVED BA TO DS   
   MOV CX,04      ;COUNTER IS INITIALISED TO 4 AS THERE ARE 5 NUMBERS
   MOV BX,CX      ;SAVED COUNTER COUNTER TO BX REGISTER
   MOV SI,0         ;TO POINT FIRST DATA OF VARIABLE NUM, SI IS INITIALISED 0
   MOV AH,00      ;USED FOR FLAG
START:   MOV AL,NUM[SI]      ;FIRST DATA FROM MEMORY IS SAVED IN AL REGISTER
     CALL PROCESS
   CMP SI,4         ;CHECKS IF SI CONTENT REACHED TO LAST DATA POSITION      
   JNE CONTD      ;IF NOT REACHED JUMPS TO CONTINUE OTHERWISE CHECKS FOR FLAG AH
   CMP AH,1      ;IF AGAIN (AH != 1) THEN SORTING IS COMPLETED
   JNE CONTD      ;AND JUMPS TO CONTINUE OTHERWISE
   MOV SI,0         ;AGAIN SI IS INITIALISED AND
   DEC BX         ;COUNTER SAVED IN BX IS DECREMENT BY 1
   MOV CX,BX      ;COMPLETE 1 FULL COUNTER MEANS GREATEST DATA IS AT LAST POSITION
   MOV AH,0      ;AND IS NOT NECESSARY TO CHECK SO FLAG ANGAIN IS SET TO 0
CONTD: LOOP START
   MOV AX,4C00H      ;VALUE 4C IN AH REGISTER
   INT 21H         ;THIS INTERRUPT TERMINATES THE PROGRAM
MAIN ENDP
END MAIN

View user profile

2 Re: Sorting by insertion method on 12th March 2009, 9:52 am

jaiparivesh

avatar
Administrator
j hos timro ma detail tanna cha
love to c your coding

thnakx again

View user profile https://www.alertpay.com/?ExlPku5EtIiST4N2a1hiEg%3d%3d

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum