amir071
سه شنبه 17 آذر 1394, 17:48 عصر
سلام دوستان ، بنده یک پروژه اسمبلی داشتم که طبق چیزایی که بهم گفته شد نوشتم (اسم از ورودی میگیره و چاپ میکنه ، حالا یک مشکل دارم و نمیتونم حلش کنم ، کسی میدونه چجور اروری که در اجرای برنامه میده رو رفع کنم؟! خودم فکر میکنم باید توی jc تغییراتی بدم
.stack 100h.data
mesg1 db 'what is your name? ',"$"
mesg2 db 'error ',"$"
mesg3 db 'more... ',"$"
namepar label byte
maxlen db 35
namelen db ?
st_name db 35 dup(20h),0dh,0ah ;student name
st_mame2 db 37 dup(32),"$"
len_name dw ?
dollar db "$"
text db 'reza',"$"
filename db "C:\emu8086\vdrive\C\name.txt",0
handler dw ?
;in_handle dw ?
byte_read dw ?
line db ?
key db 3 dup(?)
.code
;INITIALIZE DATA SEGMENT.
mov ax,@data
mov ds,ax
mov ah,09h
mov dx, offset mesg1
int 21h
mov ah,0ah
lea dx, maxlen
int 21h
;CREATE FILE.
mov ah, 3ch
mov cx, 0
mov dx, offset filename
int 21h
;PRESERVE FILE HANDLER RETURNED.
mov handler, ax
;WRITE STRING.
mov ah,40h
mov bx, handler
mov cx,37
lea dx,st_name
int 21h
jc error_write
error_write:
mov ah,09h
mov dx, offset mesg2
int 21h
; mov ah, 40h
; mov bx, handler
; mov cx, 5 ;STRING LENGTH.
; mov dx, offset text
; int 21h
;CLOSE FILE (OR DATA WILL BE LOST).
mov ah, 3eh
mov bx, handler
int 21h
;OPEN FILE
mov ah,3dh ;set function number to open file
mov al,1 ; set file access mode as 1 i.e. write access
mov dx,seg filename ;mov segment address of filename in which
mov ds,dx ; it is appearing, to register dx and then to ds
mov dx,offset filename ;points to filename
int 21h
; call sofrware interrupt of type 21h
mov handler,ax
; lea dx,filename
; mov ah,3dh
; mov al,00h
; int 21h
;
jc error_open
error_open:
mov ah,09h
mov dx, offset mesg2
int 21h
;READ FROM FILE
loop1:
mov ah,3fh
lea dx,st_name
mov bx,handler
mov cx,37
int 21h
jc error_read
error_read:
mov ah,09h
mov dx, offset mesg2
int 21h
mov byte_read,ax
cmp byte_read,0
je final
cmp byte ptr st_name,1ah
je final
inc line
cmp line,22
jne line_1_21
mov ah,09h
mov dx, offset mesg3
int 21h
lea dx,key
mov ah,3fh
mov bx,0000h
mov cx,3
int 21h
mov ah,6h ; code clear screen
mov al,25
mov ch,0
mov cl,0
mov dh,24
mov dl,79
mov bh,7
int 10h
mov line,0
line_1_21:
mov ah,09h
mov dx, offset st_name
int 21h
jmp loop1
final:
mov bx,handler
;CLOSE FILE (OR DATA WILL BE LOST).
mov ah, 3eh
mov bx, handler
int 21h
;FINISH THE PROGRAM.
mov ax,4c00h
int 21h
.stack 100h.data
mesg1 db 'what is your name? ',"$"
mesg2 db 'error ',"$"
mesg3 db 'more... ',"$"
namepar label byte
maxlen db 35
namelen db ?
st_name db 35 dup(20h),0dh,0ah ;student name
st_mame2 db 37 dup(32),"$"
len_name dw ?
dollar db "$"
text db 'reza',"$"
filename db "C:\emu8086\vdrive\C\name.txt",0
handler dw ?
;in_handle dw ?
byte_read dw ?
line db ?
key db 3 dup(?)
.code
;INITIALIZE DATA SEGMENT.
mov ax,@data
mov ds,ax
mov ah,09h
mov dx, offset mesg1
int 21h
mov ah,0ah
lea dx, maxlen
int 21h
;CREATE FILE.
mov ah, 3ch
mov cx, 0
mov dx, offset filename
int 21h
;PRESERVE FILE HANDLER RETURNED.
mov handler, ax
;WRITE STRING.
mov ah,40h
mov bx, handler
mov cx,37
lea dx,st_name
int 21h
jc error_write
error_write:
mov ah,09h
mov dx, offset mesg2
int 21h
; mov ah, 40h
; mov bx, handler
; mov cx, 5 ;STRING LENGTH.
; mov dx, offset text
; int 21h
;CLOSE FILE (OR DATA WILL BE LOST).
mov ah, 3eh
mov bx, handler
int 21h
;OPEN FILE
mov ah,3dh ;set function number to open file
mov al,1 ; set file access mode as 1 i.e. write access
mov dx,seg filename ;mov segment address of filename in which
mov ds,dx ; it is appearing, to register dx and then to ds
mov dx,offset filename ;points to filename
int 21h
; call sofrware interrupt of type 21h
mov handler,ax
; lea dx,filename
; mov ah,3dh
; mov al,00h
; int 21h
;
jc error_open
error_open:
mov ah,09h
mov dx, offset mesg2
int 21h
;READ FROM FILE
loop1:
mov ah,3fh
lea dx,st_name
mov bx,handler
mov cx,37
int 21h
jc error_read
error_read:
mov ah,09h
mov dx, offset mesg2
int 21h
mov byte_read,ax
cmp byte_read,0
je final
cmp byte ptr st_name,1ah
je final
inc line
cmp line,22
jne line_1_21
mov ah,09h
mov dx, offset mesg3
int 21h
lea dx,key
mov ah,3fh
mov bx,0000h
mov cx,3
int 21h
mov ah,6h ; code clear screen
mov al,25
mov ch,0
mov cl,0
mov dh,24
mov dl,79
mov bh,7
int 10h
mov line,0
line_1_21:
mov ah,09h
mov dx, offset st_name
int 21h
jmp loop1
final:
mov bx,handler
;CLOSE FILE (OR DATA WILL BE LOST).
mov ah, 3eh
mov bx, handler
int 21h
;FINISH THE PROGRAM.
mov ax,4c00h
int 21h