נשלח בתאריך: 17 April 2005 בשעה 23:16 | | IP רשוּם
|
|
|
|
זה הפתרון שלי לתרגיל השני עבדתי על זה יום שלם אבל עדיין לא מבצע את מה שנדרש במלואה
הקוד:
.model small .stack 100 .data std1 db 10 dup(00h)
num db 10
msg1 db 'pls enter your choise : ',0ah,0dh,'0. Update',0ah,0dh,'1. Search student by shift .',0ah,0dh,'2. for exit $'
msg2 db 'enter the number of student$'
msg3 db 'enter the first day$'
msg4 db 'enter the second day$'
msg5 db 'enter the day of shift$'
error db 'input out of range , please enter again$'
error2 db 'please enter diffrent number$'
msg6 db 'no student registred to this day$'
msg7 db 'search result : $' finish db 'end of program$' ;--------------------------------- .code begin proc far mov ax,@data mov ds,ax mov es,ax ;--------------------------------- &n bsp; mnu:
lea di,std1 lea ax,msg1 push ax ;push the menu messege call dsp_mnu   ; ;printing menu mov ax,2 ;set the range push ax ;move to stack call getc ;get the char and check sub bh,bh sub ah,ah mov bl,al cmp bx,0h &nbs p; jnz kelet1 ;if bx != 0 jump to kelet1 lea ax,error2 ;else : push ax ;push error2 to stack push di lea ax,msg2 ;push msg2 to stack push ax lea ax,msg3 ;push msg3 to stack push ax lea ax,msg4 ;push msg4 to stack push ax call choice0
kelet1:
cmp bx,1h jnz kelet2 ;if bx != 0 jump to kelet2 lea ax,msg6 push ax lea ax,msg7 push ax lea ax,msg5 push ax mov al,num sub ah,ah push ax push di call choice1
kelet2:
cmp bl,2h jnz mnu lea dx,finish call new_line call print
mov ax,4c00h int 21h begin endp
;--------------------------------------------
dsp_mnu proc
push bp mov bp,sp push dx mov dx,[bp+4] call print pop dx pop bp ret 2
dsp_mnu endp ;--------------------------------------------
new_line proc mov dl,0ah mov ah,2 int 21h mov dl,0dh mov ah,2 int 21h ret new_line endp
;--------------------------------------------
print proc mov ah,09h int 21h ret print endp
;----------------------------------------------
getc proc
push bp mov bp,sp push bx push dx
again : mov ah,1 int 21h sub al,30h mov bx,[bp+4] sub ah,ah cmp ax,0h jl mistake cmp ax,bx jg mistake jmp exit
mistake :
call new_line lea dx,error call print jmp again exit: pop dx pop bx pop bp ret 2
getc endp
;-------------------------------------
proc bit_onn
push bp mov bp,sp push di push cx mov di,[bp+6] mov cx,[bp+4] mov al,1 shl al,cl mov cx,[di] or cl,al mov [di],cl pop cx pop di pop bp ret 4
bit_onn endp ;------------------------------------
choice0 proc
push bp mov bp,sp push cx push di push dx mov di,[bp+10] mov dx,[bp+8] call print call new_line mov ax,9 push ax call getc sub ah,ah add di,ax mov ax,0h mov [di],ax mov dx,[bp+6] call print call new_line mov ax,6 push ax call getc push di sub ah,ah mov cx,ax push ax call bit_onn mov dx,[bp+4] call print call new_line mov ax,6 push ax
again2:
call getc sub ah,ah cmp ax,cx jz mistake2 push di sub ah,ah push ax call bit_onn jmp exit2
mistake2:
mov dx,[bp+12] call print call new_line jmp again2
exit2: pop dx pop di pop cx pop bp ret 10
choice0 endp ;----------------------------------------
choice1 proc
push bp mov bp,sp mov di,[bp+4] push bx push cx push dx mov dx,[bp+8] call print call new_line mov ax,6 push ax call getc mov bl,al mov al,1 mov cl,bl shl al,cl mov bl,al mov cx,[bp+6] add di,cx sub di,1 sub bh,bh sub dx,dx lable1: mov al,[di] and al,bl cmp al,0h je skip add bh,1 push di
skip: sub di,1 loop lable1 sub dx,dx mov dl,bh cmp dx,0h jne print_result mov dx,[bp+12] push dx jmp exit3 &nbs p; mov cx,dx
print_result:
pop ax add al,30h mov ah,2 int 21h mov dl,20h &nb sp; ;space mov ah,2 int 21h
loop print_result exit3:
pop dx pop cx pop bx pop di pop bp ret 10
choice1 endp end
|