;INSERT_ONE--G5_9
;**********************************************************
datarea segment			;define data segment
  x		dw	?
  array_head	dw	3,5,15,23,37,49,52,65,78,99
  array_end	dw	105
  n		dw	32	
datarea ends
;**********************************************************
prognam segment			;defint code segment
;----------------------------------------------------------
main	proc	far		;main part of program

	assume cs:prognam,ds:datarea

start:				;starting execution address

;set up stack for return
	push	ds		;save old data segment
	sub	ax,ax		;put zero in AX	
	push	ax		;save it on stack

;set DS register to current data segment
	mov	ax,datarea	;datarea segment addr
	mov	ds,ax	  	;  into DS register
  
;MAIN PART OF PROGRAM GOES HERE
	mov	ax,n
	mov	array_head-2,0ffffh
	mov	si,0
compare:cmp	array_end[si],ax
	jle	insert
	mov	bx,array_end[si]
	mov	array_end[si+2],bx
	sub	si,2
	jmp	short	compare
insert:	mov	array_end[si+2],ax
	ret			;return to DOS

main	endp			;end of main part of program
;----------------------------------------------------------
prognam ends			;end of code segment
;**********************************************************

	end	start		;end assembly
