Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; You may customize this and other start-up templates;
- ; The location of this template is c:\emu8086\inc\0_com_template.txt
- org 100h
- .model small
- .stack 100
- .Data
- temp dw 0
- temp2 dw 0
- counter db 1
- index dw 0
- number dw 50 dup(?)
- buffer db 1024 dup(?)
- res dw 0
- lngw dw 0
- now db 0
- msg db " , ","$"
- msg1 db 0dH,0aH," list of digite in file "0dH,0aH,,"$"
- msg2 db 0dH,0aH," Add Result "0dH,0aH,,"$"
- msg3 db 0dH,0aH," list of sortes digite in file "0dH,0aH,,"$"
- start db " start final project:",0dH,0aH,"$"
- end_msg db 0dH,0aH,0dH,0aH,"press any key to exit." ,"$"
- line db 0dH,0aH,0dH,0aH,"==============================================================",0dH,0aH,0dH,0aH,"$"
- src db 'c:\source.txt',00H
- s_Handle dw ?
- text db "nm3kfl9nf32k100." ,0dH,0aH, "ljdcl jjds lkjd 54 .#"
- buffer_size dw ?
- textsize = $ - offset text ;to calculate size of text it minus '$' wHicH is end of text string from start point of string
- .CODE
- ;===================
- mov ax,@Data
- mov ds,ax
- mov ax,0
- ;===================
- ;print start message
- mov dx,offset start
- mov aH,09H
- int 21H
- ; create and open file: c:\emu8086\vdrive\C\source.txt
- mov aH, 3cH
- mov cx, 0H
- lea dx, src
- int 21H
- jc err
- mov s_Handle, ax
- ; write to c:\emu8086\vdrive\C\source.txt:
- mov aH, 40H
- mov bx, s_Handle
- mov dx, offset text
- mov cx, textsize
- int 21H
- ; close c:\emu8086\vdrive\C\source.txt
- mov aH, 3eH
- mov bx, s_Handle
- int 21H
- ;open source file
- lea dx,src
- mov al,00H
- mov aH,3dH
- int 21H
- ;read source file
- mov ax,0
- mov bx,s_Handle
- mov buffer_size,1024
- mov aH,3fH
- lea dx,buffer
- mov cx,buffer_size
- int 21H
- jc err
- mov buffer_size,ax
- ;close source file
- mov aH,3eH
- mov bx,s_Handle
- int 21H
- err:
- nop
- ; set degite in new arraye and add digite in ever section
- mov si,0
- mov di,0
- start0:
- cmp counter,4
- jb H
- call set_arraye
- H:
- mov al,buffer[si]
- cmp al,48
- jnb test2
- cmp counter,1
- je H1
- call set_arraye
- H1:
- inc si
- cmp buffer[si],35
- je final
- jmp start0
- test2:
- cmp al , 58
- jb action
- cmp counter,1
- je H2
- call set_arraye
- H2:
- inc si
- cmp buffer[si],35
- je final
- jmp start0
- action:
- sub al,48
- cmp counter,1
- je firstset
- cmp counter,2
- je tenmull
- cmp counter,3
- je tenmull
- firstset:
- mov aH,0
- mov temp,ax
- inc counter
- inc si
- jmp start0
- tenmull:
- mov aH,0
- mov bx,ax
- mov ax, temp
- mov dl,10
- mul dl
- add ax, bx
- mov temp,ax
- inc si
- inc counter
- jmp start0
- final:
- ;print list of digite
- mov dx,offset msg1
- mov aH,09H
- int 21H
- ;print list of digite
- mov si,0
- L:
- mov ax,number[si]
- call print_ax
- mov dx,offset msg
- mov aH,09H
- int 21H
- inc si
- inc si
- cmp si,index
- jb L
- call print_nl
- ;print Result Add
- mov dx,offset msg2
- mov aH,09H
- int 21H
- ;print result add
- mov ax,res
- call print_ax
- call print_nl
- mov temp,0
- call sort_bubble
- ;print prompt message to end tHe program
- mov dx,offset end_msg
- mov aH,09H
- int 21H
- ;wait for any key to end tHe program
- mov aH,0
- int 16H
- mov aH,4cH
- int 21H
- ret
- print_ax proc
- cmp ax, 0
- jne print_ax_r
- pusH ax
- mov al, '0'
- mov aH, 0eH
- int 10H
- pop ax
- ret
- print_ax_r:
- pusHa
- mov dx, 0
- cmp ax, 0
- je pn_done
- mov bx, 10
- div bx
- call print_ax_r
- mov ax, dx
- add al, 30H
- mov aH, 0eH
- int 10H
- jmp pn_done
- pn_done:
- popa
- ret
- endp
- print_nl proc
- pusH ax
- pusH dx
- mov aH, 2
- mov dl, 0DH
- int 21H
- mov dl, 0AH
- int 21H
- pop dx
- pop ax
- ret
- endp
- set_arraye proc
- mov di,index
- mov ax,temp
- mov number[di],0
- mov number[di],ax
- mov ax,number[di]
- inc di
- inc di
- mov index,di
- mov temp,0
- mov counter,1
- add ax,res
- mov res,ax
- ret
- endp
- sort_bubble proc
- ;sort list of digite
- mov cx,index
- sort:
- cmp cx , 0
- jbe end_sort
- mov si , 0
- mov di , 2
- for:
- mov ax , number[si]
- mov dx , number[di]
- cmp dx , ax
- jbe loopinc
- xcHg dx , ax
- mov number[si] , ax
- mov number[di] , dx
- loopinc:
- inc si
- inc si
- inc di
- inc di
- cmp si,cx
- jb for
- dec cx
- jmp sort
- end_sort:
- ;print sortest list of Digite
- mov dx,offset msg3
- mov aH,09H
- int 21H
- ;print sortes list
- mov si,0
- mov bx,index
- for1:
- mov ax,number[si]
- call print_ax
- mov dx,offset msg
- mov aH,09H
- int 21H
- inc si
- inc si
- cmp si,bx
- jb for1
- ret
- endp
- end
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement