Re: Обьясните плиз
Добавлено: 28 янв 2008, 23:38
программа начинается с метки _start, там же находится процедура printstr, а вот что находиться в тот момент в DX - никому не известно.
Код: Выделить всё
model small
.386
.stack 100h
.data
msg1 db "Enter name of directory: $"
msg2 db "Directory created successful!",0dh,0ah,"$"
msg3 db "Enter name of file: $"
msg4 db "File created successful!",0dh,0ah,"$"
filehandle dw ?
newst db 0dh,0ah,"$"
errmsg db "Input/output error! $"
inputstrmax db 0ffh
inputstrsize db ?
inputstr db 0ffh dup (?)
.code
_start:
mov ax,@data
mov ds,ax
jmp _real_start
printstr proc
mov ah,09h
int 21h
ret
printstr endp
readstr proc
lea dx,inputstrmax
mov ah,0ah
int 21h
movzx cx,inputstrsize
lea bx,inputstr
add bx,cx
mov byte ptr [bx],0
ret
readstr endp
_real_start:
;-----------------------------Creating a new directory-------------------------
lea dx,msg1
call printstr
call readstr
mov ah,039h
lea dx,inputstr
int 21h
jc _ioerror
lea dx,newst
call printstr
lea dx,msg2
call printstr
;----------------------------Entering a new directory-------------------------------
mov ah,03bh
lea dx,inputstr
int 21h
jc _ioerror
;----------------------------Creating a new file with it's opening------------------
lea dx,msg3
call printstr
call readstr
mov ah,03ch
xor cx,cx
lea dx,inputstr
int 21h
jc _ioerror
lea dx,newst
call printstr
lea dx,msg4
call printstr
mov filehandle,ax
;---------------------------Closing a new file----------------------------------------
mov ah,03eh
mov bx,filehandle
int 21h
jmp _wait
_ioerror:
lea dx,newst
call printstr
lea dx,errmsg
call printstr
_wait:
mov ah,0
int 16h
mov ax,4c00h
int 21h
end _start
Код: Выделить всё
.model small
.386
.stack 100h
.data
msg1 db "Enter name of directory: $"
msg2 db "Directory created successful!",0dh,0ah,"$"
msg3 db "Enter name of file: $"
msg4 db "File created successful!",0dh,0ah,"$"
msg5 db "Enter a string: $"
msg6 db "Writing to file is succsessful!",0dh,0ah,"$"
msg7 dw 2 dup (?),"$"
filehandle dw ?
newst db 0dh,0ah,"$"
errmsg db "Input/output error! $"
inputstrmax db 0ffh
inputstrsize db ?
inputstr db 0ffh dup (?)
.code
_start:
mov ax,@data
mov ds,ax
mov es,ax
jmp _real_start
printstr proc
mov ah,09h
int 21h
ret
printstr endp
readstr proc
lea dx,inputstrmax
mov ah,0ah
int 21h
movzx cx,inputstrsize
lea bx,inputstr
add bx,cx
mov byte ptr [bx],0
ret
readstr endp
_real_start:
;-----------------------------Creating a new directory-------------------------
lea dx,msg1
call printstr
call readstr
mov ah,039h
lea dx,inputstr
int 21h
jc _ioerror
lea dx,newst
call printstr
lea dx,msg2
call printstr
;----------------------------Entering a new directory-------------------------------
mov ah,03bh
lea dx,inputstr
int 21h
jc _ioerror
;----------------------------Creating a new file with it's opening------------------
lea dx,msg3
call printstr
call readstr
mov ah,03ch
xor cx,cx
lea dx,inputstr
int 21h
jc _ioerror
lea dx,newst
call printstr
lea dx,msg4
call printstr
mov filehandle,ax
;---------------------------Writing data to file-------------------------------------
lea dx,msg5
call printstr
call readstr
mov ah,40h
mov bx,filehandle
movzx cx,inputstrsize
jc _ioerror
lea dx,newst
call printstr
lea dx,msg6
call printstr
;---------------------------Closing a new file----------------------------------------
mov ah,03eh
mov bx,filehandle
int 21h
jmp _wait
_ioerror:
lea dx,newst
call printstr
lea dx,errmsg
call printstr
_wait:
mov ah,0
int 16h
mov ax,4c00h
int 21h
end _start
Код: Выделить всё
.model small
.386
.stack 100h
.data
msg1 db "Enter name of directory: $"
msg2 db "Directory created successful!",0dh,0ah,"$"
msg3 db "Enter name of file: $"
msg4 db "File created successful!",0dh,0ah,"$"
msg5 db "Enter a string: $"
msg6 db "Writing to file is succsessful!",0dh,0ah,"$"
msg7 dw 2 dup (?),"$"
filehandle dw ?
newst db 0dh,0ah,"$"
errmsg db "Input/output error! $"
inputstrmax db 0ffh
inputstrsize db ?
inputstr db 0ffh dup (?)
.code
_start:
mov ax,@data
mov ds,ax
mov es,ax
jmp _real_start
printstr proc
mov ah,09h
int 21h
ret
printstr endp
readstr proc
lea dx,inputstrmax
mov ah,0ah
int 21h
movzx cx,inputstrsize
lea bx,inputstr
add bx,cx
mov byte ptr [bx],0
ret
readstr endp
_real_start:
;-----------------------------Creating a new directory-------------------------
lea dx,msg1
call printstr
call readstr
mov ah,039h
lea dx,inputstr
int 21h
jc _ioerror
lea dx,newst
call printstr
lea dx,msg2
call printstr
;----------------------------Entering a new directory-------------------------------
mov ah,03bh
lea dx,inputstr
int 21h
jc _ioerror
;----------------------------Creating a new file with it's opening------------------
lea dx,msg3
call printstr
call readstr
mov ah,03ch
xor cx,cx
lea dx,inputstr
int 21h
jc _ioerror
lea dx,newst
call printstr
lea dx,msg4
call printstr
mov filehandle,ax
;---------------------------Writing data to file-------------------------------------
lea dx,msg5
call printstr
call readstr
movzx cx,inputstrsize
lea di,inputstr
add di,cx
mov byte ptr [di],"$"
mov ah,40h
mov bx,filehandle
int 21h
jc _ioerror
lea dx,newst
call printstr
lea dx,msg6
call printstr
;---------------------------Closing a new file----------------------------------------
mov ah,03eh
mov bx,filehandle
int 21h
jmp _wait
_ioerror:
lea dx,newst
call printstr
lea dx,errmsg
call printstr
_wait:
mov ah,0
int 16h
mov ax,4c00h
int 21h
end _start