masome
18-07-2007, 13:35
سلام!
من این برنامه را نوشته ام ولی درست کار نمی کنه!می شه بگید اشکالش چیه و باید چی کار کرد؟
صورت برنامه:
یک منو با سه گزینه ایجاد شود که در قسمت اول باید یک string را به وسیله کلیدهای مکان نما حرکت دهیم.در قسمت بعد باید وضعیت کلیدهای insert,scrolllock,capslock,numlock را بررسی کند و در قسمت بعد از برنامه خارج شود.
کد برنامه:
dataseg segment 'data'
row_up db ?
row_down db ?
left_coloum db ?
right_coloum db ?
cr equ 0dh
lf equ 0ah
menu db 0c9h,40 dup(0cdh),0bbh,cr,lf
db 0bah,2 dup(32),'please choose 1,2 or 3',2 dup(32),0bah,cr,lf
db 0bah,2 dup(32),'then press enter.',2 dup(32),0bah,cr,lf
db 0bah,40 dup(32),0bah,cr,lf
db 0bah,2 dup(32),'1)Game',2 dup(32),0bah,cr,lf
db 0bah,2 dup(32),'2)Keys staute',2 dup(32),0bah,cr,lf
db 0bah,2 dup (32),'3)Exit',2 dup(32),0bah,cr,lf
db 0c8h,40 dup(0cdh),0bch,cr,lf,"$"
msg1 db "YOU ENTERED INVALID NUMBER,PRESS ESC TO BACK.","$"
msg2 db "Inser is on.","$"
msg3 db "Caps Lock is on.","$"
msg4 db "Num Lock is on.","$"
msg5 db "Scroll Lock is on.","$"
msg6 db "press Esc to back.","$"
msg7 db "Thank you","$"
msg8 db "GOOD BYE","$"
msg9 db "press Del to back.","$"
border db 0dah,50 dup(0c4h),0bfh,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0c0h,50 dup(0c4h),0d9h,cr,lf,"$"
hello db 0c9h,7 dup(0cdh),0bbh,cr,lf
db 0bah,7 dup(32),0bah,cr,lf
db 0bah,1 dup(32),'HELLO',1 dup(32),0bah,cr,lf
db 0bah,7 dup(32),0bah,cr,lf
db 0c8h,7 dup(0c4h),0bch,cr,lf,"$"
dataseg ends
codeseg segment 'code'
main proc far
assume cs:codeseg,ds:dataseg
mov ax,dataseg
mov ds,ax
call cls
call disp_menu ;display menu
p1:
call read_char ;read character from keyboard
cmp al,49
je game ;select first item in menu
cmp al,50
je satute ;select second item in menu
cmp al,51
je exit ;select third item in menu
back:
call cls
mov dx,0c0eh
call locate ;set cursor in center
lea dx,msg1
mov ah,9h
int 21h ;print error
call read_char ;read character from keyboard
cmp al,27 ;press esc?
jne back
call cls
mov dh,5
mov dl,5
call locate ;set cursor
call disp_menu ;display menu
jmp p1
game:
call cls
mov dh,2
mov dl,30
call locate ;set cursor in(2,30)
mov ah,9h
lea dx,msg9
int 21h ;print message for back to the menu
mov dh,4
mov dl,4
call locate ;set cursor in (4,4)
call disp_border
mov dh,0bh
mov dl,1bh
call locate ;set cursor in (11,27)
call disp_hello ;request display menu
mov row_up,11
mov row_down,15
mov left_coloum,27
mov right_coloum,35
lup:
p:
call read_char ;read character from keyboard
cmp ah,72 ;press up arrow
jne L1
dec row_up
jne lup
call cls
mov dh,2
mov dl,30
call locate ;set cursor in(2,30)
mov ah,9h
lea dx,msg9
int 21h ;print message for back to the menu
mov dh,4
mov dl,4
call locate ;set cursor in (4,4)
call disp_border
dec row_down
mov dh,row_up
mov dl,left_coloum
call locate
call disp_hello
jmp lup
L1:
cmp ah,80 ;press down arrow
jne L2
inc row_down
cmp row_down,24
jnl lup
call cls
mov dh,2
mov dl,30
call locate ;set cursor in(2,30)
mov ah,9h
lea dx,msg9
int 21h ;print message for back to the menu
mov dh,4
mov dl,4
call locate ;set cursor in (4,4)
call disp_border
inc row_up
mov dh,row_up
mov dl,left_coloum
call locate
call disp_hello
jmp lup
L2:
cmp ah,75 ;press left arrow
jne L3
dec left_coloum
cmp left_coloum,4
jne lup
call cls
mov dh,2
mov dl,30
call locate ;set cursor in(2,30)
mov ah,9h
lea dx,msg9
int 21h ;print message for back to the menu
mov dh,4
mov dl,4
call locate ;set cursor in (4,4)
call disp_border
mov dh,row_up
mov dl,left_coloum
call locate
call disp_hello
jmp lup
L3:
cmp ah,77 ;press right arrow
jne L4
inc right_coloum
cmp right_coloum,55
jnl lup
call cls
mov dh,2
mov dl,30
call locate ;set cursor in(2,30)
mov ah,9h
lea dx,msg9
int 21h ;print message for back to the menu
mov dh,4
mov dl,4
call locate ;set cursor in (4,4)
call disp_border
inc left_coloum
mov dh,row_up
mov dl,left_coloum
call locate
call disp_hello
jmp lup
L4:
cmp ah,83 ;press delete key?
jne L5
call cls
mov dh,5
mov dl,5
call locate ;set cursor in (5,5)
call disp_menu
L5:
call cls
mov ah,9h
lea dx,msg1
int 21h
call read_char ;read character from keyboard
cmp ah,27 ;press Esc?
jne L5
call cls
mov dh,5
mov dl,5
call locate ;set cursor in (5,5)
call disp_menu
jmp p1
satute:
mov ah,12h
int 16h
test al,10000b
jz k2
call cls
mov dl,5
mov dh,8
call locate
lea dx,msg2
mov ah,09h
int 21h
k2:
test al,100000b
jz k3
call cls
mov dl,5
mov dh,8
call locate
lea dx,msg3
mov ah,09h
int 21h
k3:
test al,1000000b
jz k4
call cls
mov dl,5
mov dh,8
call locate
lea dx,msg4
mov ah,09h
int 21h
k4:
test al,10000000b
jz k5
call cls
mov dl,5
mov dh,8
call locate
lea dx,msg5
mov ah,09h
int 21h
k5:
call cls
mov dl,5
mov dh,8
call locate
lea dx,msg6
mov ah,09h
int 21h
p6:
call read_char ;read character from keyboard
cmp ah,27
jne p6
call cls
mov dh,5
mov dl,5
call locate ;set cursor in (5,5)
call disp_menu
jmp p1
exit:
call cls
mov dh,10
mov dl,34
call locate ;set cursor
lea dx,msg7
mov ah,09h
int 21h
mov dh,12
mov dl,36
call locate ;set cursor
lea dx,msg8
mov ah,09h
int 21h
mov ax,4c00h
int 21h
main endp
;************************************************* *************
disp_menu proc near
mov ah,9h
lea dx,menu
int 21h
ret
disp_menu endp
;************************************************* *************
disp_border proc near
mov ah,9h
lea dx,border
int 21h
ret
disp_border endp
;************************************************* *************
disp_hello proc near
mov ah,9h
lea dx,hello
int 21h
ret
disp_hello endp
;************************************************* *************
locate proc near
mov ah,2h
mov bh,0
int 10h
ret
locate endp
;************************************************* *************
cls proc near
mov ah,6h
mov al,25
mov cx,0000h
mov dx,184fh ;full screen
mov bh,7
int 10h
ret
cls endp
;************************************************* ************
read_char proc near
mov ah,10h
int 16h
ret
read_char endp
;************************************************* ************
codeseg ends
end main
من این برنامه را نوشته ام ولی درست کار نمی کنه!می شه بگید اشکالش چیه و باید چی کار کرد؟
صورت برنامه:
یک منو با سه گزینه ایجاد شود که در قسمت اول باید یک string را به وسیله کلیدهای مکان نما حرکت دهیم.در قسمت بعد باید وضعیت کلیدهای insert,scrolllock,capslock,numlock را بررسی کند و در قسمت بعد از برنامه خارج شود.
کد برنامه:
dataseg segment 'data'
row_up db ?
row_down db ?
left_coloum db ?
right_coloum db ?
cr equ 0dh
lf equ 0ah
menu db 0c9h,40 dup(0cdh),0bbh,cr,lf
db 0bah,2 dup(32),'please choose 1,2 or 3',2 dup(32),0bah,cr,lf
db 0bah,2 dup(32),'then press enter.',2 dup(32),0bah,cr,lf
db 0bah,40 dup(32),0bah,cr,lf
db 0bah,2 dup(32),'1)Game',2 dup(32),0bah,cr,lf
db 0bah,2 dup(32),'2)Keys staute',2 dup(32),0bah,cr,lf
db 0bah,2 dup (32),'3)Exit',2 dup(32),0bah,cr,lf
db 0c8h,40 dup(0cdh),0bch,cr,lf,"$"
msg1 db "YOU ENTERED INVALID NUMBER,PRESS ESC TO BACK.","$"
msg2 db "Inser is on.","$"
msg3 db "Caps Lock is on.","$"
msg4 db "Num Lock is on.","$"
msg5 db "Scroll Lock is on.","$"
msg6 db "press Esc to back.","$"
msg7 db "Thank you","$"
msg8 db "GOOD BYE","$"
msg9 db "press Del to back.","$"
border db 0dah,50 dup(0c4h),0bfh,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0b3h,50 dup(32),0b3h,cr,lf
db 0c0h,50 dup(0c4h),0d9h,cr,lf,"$"
hello db 0c9h,7 dup(0cdh),0bbh,cr,lf
db 0bah,7 dup(32),0bah,cr,lf
db 0bah,1 dup(32),'HELLO',1 dup(32),0bah,cr,lf
db 0bah,7 dup(32),0bah,cr,lf
db 0c8h,7 dup(0c4h),0bch,cr,lf,"$"
dataseg ends
codeseg segment 'code'
main proc far
assume cs:codeseg,ds:dataseg
mov ax,dataseg
mov ds,ax
call cls
call disp_menu ;display menu
p1:
call read_char ;read character from keyboard
cmp al,49
je game ;select first item in menu
cmp al,50
je satute ;select second item in menu
cmp al,51
je exit ;select third item in menu
back:
call cls
mov dx,0c0eh
call locate ;set cursor in center
lea dx,msg1
mov ah,9h
int 21h ;print error
call read_char ;read character from keyboard
cmp al,27 ;press esc?
jne back
call cls
mov dh,5
mov dl,5
call locate ;set cursor
call disp_menu ;display menu
jmp p1
game:
call cls
mov dh,2
mov dl,30
call locate ;set cursor in(2,30)
mov ah,9h
lea dx,msg9
int 21h ;print message for back to the menu
mov dh,4
mov dl,4
call locate ;set cursor in (4,4)
call disp_border
mov dh,0bh
mov dl,1bh
call locate ;set cursor in (11,27)
call disp_hello ;request display menu
mov row_up,11
mov row_down,15
mov left_coloum,27
mov right_coloum,35
lup:
p:
call read_char ;read character from keyboard
cmp ah,72 ;press up arrow
jne L1
dec row_up
jne lup
call cls
mov dh,2
mov dl,30
call locate ;set cursor in(2,30)
mov ah,9h
lea dx,msg9
int 21h ;print message for back to the menu
mov dh,4
mov dl,4
call locate ;set cursor in (4,4)
call disp_border
dec row_down
mov dh,row_up
mov dl,left_coloum
call locate
call disp_hello
jmp lup
L1:
cmp ah,80 ;press down arrow
jne L2
inc row_down
cmp row_down,24
jnl lup
call cls
mov dh,2
mov dl,30
call locate ;set cursor in(2,30)
mov ah,9h
lea dx,msg9
int 21h ;print message for back to the menu
mov dh,4
mov dl,4
call locate ;set cursor in (4,4)
call disp_border
inc row_up
mov dh,row_up
mov dl,left_coloum
call locate
call disp_hello
jmp lup
L2:
cmp ah,75 ;press left arrow
jne L3
dec left_coloum
cmp left_coloum,4
jne lup
call cls
mov dh,2
mov dl,30
call locate ;set cursor in(2,30)
mov ah,9h
lea dx,msg9
int 21h ;print message for back to the menu
mov dh,4
mov dl,4
call locate ;set cursor in (4,4)
call disp_border
mov dh,row_up
mov dl,left_coloum
call locate
call disp_hello
jmp lup
L3:
cmp ah,77 ;press right arrow
jne L4
inc right_coloum
cmp right_coloum,55
jnl lup
call cls
mov dh,2
mov dl,30
call locate ;set cursor in(2,30)
mov ah,9h
lea dx,msg9
int 21h ;print message for back to the menu
mov dh,4
mov dl,4
call locate ;set cursor in (4,4)
call disp_border
inc left_coloum
mov dh,row_up
mov dl,left_coloum
call locate
call disp_hello
jmp lup
L4:
cmp ah,83 ;press delete key?
jne L5
call cls
mov dh,5
mov dl,5
call locate ;set cursor in (5,5)
call disp_menu
L5:
call cls
mov ah,9h
lea dx,msg1
int 21h
call read_char ;read character from keyboard
cmp ah,27 ;press Esc?
jne L5
call cls
mov dh,5
mov dl,5
call locate ;set cursor in (5,5)
call disp_menu
jmp p1
satute:
mov ah,12h
int 16h
test al,10000b
jz k2
call cls
mov dl,5
mov dh,8
call locate
lea dx,msg2
mov ah,09h
int 21h
k2:
test al,100000b
jz k3
call cls
mov dl,5
mov dh,8
call locate
lea dx,msg3
mov ah,09h
int 21h
k3:
test al,1000000b
jz k4
call cls
mov dl,5
mov dh,8
call locate
lea dx,msg4
mov ah,09h
int 21h
k4:
test al,10000000b
jz k5
call cls
mov dl,5
mov dh,8
call locate
lea dx,msg5
mov ah,09h
int 21h
k5:
call cls
mov dl,5
mov dh,8
call locate
lea dx,msg6
mov ah,09h
int 21h
p6:
call read_char ;read character from keyboard
cmp ah,27
jne p6
call cls
mov dh,5
mov dl,5
call locate ;set cursor in (5,5)
call disp_menu
jmp p1
exit:
call cls
mov dh,10
mov dl,34
call locate ;set cursor
lea dx,msg7
mov ah,09h
int 21h
mov dh,12
mov dl,36
call locate ;set cursor
lea dx,msg8
mov ah,09h
int 21h
mov ax,4c00h
int 21h
main endp
;************************************************* *************
disp_menu proc near
mov ah,9h
lea dx,menu
int 21h
ret
disp_menu endp
;************************************************* *************
disp_border proc near
mov ah,9h
lea dx,border
int 21h
ret
disp_border endp
;************************************************* *************
disp_hello proc near
mov ah,9h
lea dx,hello
int 21h
ret
disp_hello endp
;************************************************* *************
locate proc near
mov ah,2h
mov bh,0
int 10h
ret
locate endp
;************************************************* *************
cls proc near
mov ah,6h
mov al,25
mov cx,0000h
mov dx,184fh ;full screen
mov bh,7
int 10h
ret
cls endp
;************************************************* ************
read_char proc near
mov ah,10h
int 16h
ret
read_char endp
;************************************************* ************
codeseg ends
end main