baran.moradi
سه شنبه 30 اردیبهشت 1393, 15:26 عصر
سلام خسته نباشید درمورد کد برنامه زیر یه توضیح میخواستم،ممنونم
رو برنامه emulator8086اجرا میشه اما در موردش بیشتر میخواستم بدونم
.model small
.stack 128
.data
buffer_1 db 25,?,25 dup(' ')
buffer_2 db 25 dup(' '),'$'
handle dw 0
file_name db 'c:\student.dat',00h
er_creat db "Error create file",13,10,'$'
er_write db "Error write file",13,10,'$'
er_close db "Error close file",13,10,'$'
pkey db 13,10,"File successfully craeted,press any key for end program...$"
.code
start:
.startup
mov es,dx
call clrscr
mov ah,02 ;set cursor
mov bh,00
mov dl,10;soton
mov dh,10;satr
int 10h
call creat_file
mov ah,0ah ;input keyboard
mov dx,offset buffer_1
int 21h
call write_file
call close_file
lea dx, pkey
mov ah, 9
int 21h ; output string at ds:dx
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
creat_file proc near
mov ah,3ch
mov cx,0
lea dx,file_name
int 21h
jc c_error
mov handle,ax
jmp c_exit
c_error:
mov dx,offset er_creat
call show_er
c_exit:ret
creat_file endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
write_file proc
mov ah,40h
mov bx,handle
mov cx,5
mov dx,offset buffer_1+2
int 21h
jnc w_exit
lea dx, er_write
call show_er
w_exit: ret
write_file endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
close_file proc
mov ah,3eh
mov bx,handle
int 21h
jnc cl_exit
mov dx,offset er_close
call show_er
cl_exit:ret
close_file endp
;>>>>>>>>>>>>>>>>>>>>>>>>>
clrscr proc near
; Code for clearing the screen, equvalent to clrscr() in C,C++
mov ax,0600h ;AH=06(SCROLL),AL=00 (FULL SCREEN)
mov bh,07h ;0=BLACK BAKGROUND,7=WHITE FOREGROUND
mov cx,0000h ;UPPER LEFT ROW:COLUMN
mov dx,2479h ;24TH ROW,79TH COLUMN
int 10h ;EXECUTE INTERRUPT 10H [ VIDEO BIOS]
mov ah,02h ;FUNCTION FOR SETTING THE CURSOR
mov bh,0 ;STARTING PAGE NUMBER
mov dh,0 ;STARTING ROW
mov dl,0 ;STARTING COLUMN
int 10h ;EXECUTE INTERRUPT 10H [ VIDEO BIOS]
ret
endp
;>>>>>>>>>>>>>>>>>>>>>>>>>
show_er proc near
mov ah,9
int 21h
ret
endp
end start
org 100h
mov ah, 3ch
mov cx, 0
mov dx, offset filename
mov ah, 3ch
int 21h ; create file...
mov handle, ax
mov bx, handle
mov dx, offset data
mov cx, data_size
mov ah, 40h
int 21h ; write to file...
mov al, 0
mov bx, handle
mov cx, 0
mov dx, 7
mov ah, 42h
int 21h ; seek...
mov bx, handle
mov dx, offset buffer
mov cx, 4
mov ah, 3fh
int 21h ; read from file...
mov bx, handle
mov ah, 3eh
int 21h ; close file...
ret
filename db "c:\myfile.txt", 0
handle dw ?
data db " hello files! "
data_size=$-offset data
buffer db 4 dup(' ')
رو برنامه emulator8086اجرا میشه اما در موردش بیشتر میخواستم بدونم
.model small
.stack 128
.data
buffer_1 db 25,?,25 dup(' ')
buffer_2 db 25 dup(' '),'$'
handle dw 0
file_name db 'c:\student.dat',00h
er_creat db "Error create file",13,10,'$'
er_write db "Error write file",13,10,'$'
er_close db "Error close file",13,10,'$'
pkey db 13,10,"File successfully craeted,press any key for end program...$"
.code
start:
.startup
mov es,dx
call clrscr
mov ah,02 ;set cursor
mov bh,00
mov dl,10;soton
mov dh,10;satr
int 10h
call creat_file
mov ah,0ah ;input keyboard
mov dx,offset buffer_1
int 21h
call write_file
call close_file
lea dx, pkey
mov ah, 9
int 21h ; output string at ds:dx
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
creat_file proc near
mov ah,3ch
mov cx,0
lea dx,file_name
int 21h
jc c_error
mov handle,ax
jmp c_exit
c_error:
mov dx,offset er_creat
call show_er
c_exit:ret
creat_file endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
write_file proc
mov ah,40h
mov bx,handle
mov cx,5
mov dx,offset buffer_1+2
int 21h
jnc w_exit
lea dx, er_write
call show_er
w_exit: ret
write_file endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
close_file proc
mov ah,3eh
mov bx,handle
int 21h
jnc cl_exit
mov dx,offset er_close
call show_er
cl_exit:ret
close_file endp
;>>>>>>>>>>>>>>>>>>>>>>>>>
clrscr proc near
; Code for clearing the screen, equvalent to clrscr() in C,C++
mov ax,0600h ;AH=06(SCROLL),AL=00 (FULL SCREEN)
mov bh,07h ;0=BLACK BAKGROUND,7=WHITE FOREGROUND
mov cx,0000h ;UPPER LEFT ROW:COLUMN
mov dx,2479h ;24TH ROW,79TH COLUMN
int 10h ;EXECUTE INTERRUPT 10H [ VIDEO BIOS]
mov ah,02h ;FUNCTION FOR SETTING THE CURSOR
mov bh,0 ;STARTING PAGE NUMBER
mov dh,0 ;STARTING ROW
mov dl,0 ;STARTING COLUMN
int 10h ;EXECUTE INTERRUPT 10H [ VIDEO BIOS]
ret
endp
;>>>>>>>>>>>>>>>>>>>>>>>>>
show_er proc near
mov ah,9
int 21h
ret
endp
end start
org 100h
mov ah, 3ch
mov cx, 0
mov dx, offset filename
mov ah, 3ch
int 21h ; create file...
mov handle, ax
mov bx, handle
mov dx, offset data
mov cx, data_size
mov ah, 40h
int 21h ; write to file...
mov al, 0
mov bx, handle
mov cx, 0
mov dx, 7
mov ah, 42h
int 21h ; seek...
mov bx, handle
mov dx, offset buffer
mov cx, 4
mov ah, 3fh
int 21h ; read from file...
mov bx, handle
mov ah, 3eh
int 21h ; close file...
ret
filename db "c:\myfile.txt", 0
handle dw ?
data db " hello files! "
data_size=$-offset data
buffer db 4 dup(' ')