negar_1366
دوشنبه 07 دی 1388, 20:05 عصر
اماکنش هست چند تا از اشکالای این برنامه رو بگین
include io.h ;1
title program1 ;2
;3
stacksg segment para stack 'stack' ;4
stacksg ends ;5
;6
;7
;8
datasg segment para ;9
;10
msg1 db "(1) N!","$" ;11
msg2 db 13,10,"(2) 2^N","$" ;12
msg3 db 13,10,"(3) Is N a prime number?","$" ;13
msg4 db 13,10,"(4) Exit","$" ;14
msg5 db 13,10,"Enter your choice:","$" ;15
msg6 db "Number is not prime","$" ;16
msg7 db "Number is prime","$" ;17
msg8 db "2^N Is : ","$" ;18
msg9 db "Fact Number Is :","$" ;19
msg10 db 13,10,"Enter number between 1 to 8 :","$" ;20
msg11 db 13,10,"Enter number between 1 to 14 :","$" ;21
msg12 db 13,10,"Enter number:","$" ;22
;23
;24
one dw 1 ;25
two dw 2 ;26
three dw 3 ;27
fore dw 4 ;28
;29
number db 7 dup(?) ;30
;31
;32
;33
datasg ends ;34
;35
;36
;37
;38
codesg segment para 'code' ;39
;40
;--------------------------------------- ;41
;42
fact proc far ;43
cmp ax,1 ;44
jg L1 ;45
ret ;46
L1: push ax ;47
dec ax ;48
call fact ;49
pop cx ;50
mul cx ;51
ret ;52
fact endp ;53
;54
;--------------------------------------- ;55
;56
prime proc far ;57
;58
cbw ;59
mov bx,ax ;60
;61
mov cx,3 ;62
compare: ;63
div cx ;64
cmp dl,0 ;65
je notprime ;66
add cx,2 ;67
cmp cx,bx ;68
jae isprime ;69
jmp compare ;70
;71
notprime: ;72
output msg6 ;73
jmp exit ;74
;75
isprime: ;76
output msg7 ;77
;78
exit: ;79
call menu ;80
;81
prime endp ;82
;83
;--------------------------------------- ;84
;85
tavan proc far ;86
mov cx,ax ;87
mov ax,1 ;88
ta: ;89
mul bx ;90
loop ta ;91
output msg8 ;92
itoa number,ax ;93
output number ;94
tavan endp ;95
;96
;--------------------------------------- ;97
;98
menu proc far ;99
output msg1 ;100
output msg2 ;101
output msg3 ;102
output msg4 ;103
output msg5 ;104
menu endp ;105
;106
;--------------------------------------- ;107
;108
;109
;110
main proc far ;111
assume ss:stacksg;ds:datasg;cs:codesg ;112
mov ax,datasg ;113
mov ds,ax ;114
;115
call menu ;116
inputs number,7 ;117
atoi number ;118
;119
cmp ax,one ;120
je one1 ;121
cmp ax,two ;122
je two2 ;123
cmp ax,three ;124
je three3 ;125
cmp ax,fore ;126
je fore4 ;127
;128
;129
;130
one1: ;131
output msg10 ;132
inputs number,7 ;133
atoi number ;134
cmp ax,8 ;135
jg one1 ;136
mov cx,ax ;137
call fact ;138
output msg9 ;139
itoa number,ax ;140
output number ;141
call menu ;142
two2: ;143
output msg11 ;144
inputs number,7 ;145
atoi number ;145
cmp ax,14 ;147
jg two2 ;148
call tavan ;149
call menu ;150
three3: ;151
output msg12 ;152
inputs number,7 ;153
atoi number ;154
mov bx,2 ;155
call prime ;156
call menu ;157
fore4: ;158
mov ax,4c00h ;159
int 21h ;160
;161
;162
;163
;164
;165
main endp ;166
codesg ends ;167
end main
include io.h ;1
title program1 ;2
;3
stacksg segment para stack 'stack' ;4
stacksg ends ;5
;6
;7
;8
datasg segment para ;9
;10
msg1 db "(1) N!","$" ;11
msg2 db 13,10,"(2) 2^N","$" ;12
msg3 db 13,10,"(3) Is N a prime number?","$" ;13
msg4 db 13,10,"(4) Exit","$" ;14
msg5 db 13,10,"Enter your choice:","$" ;15
msg6 db "Number is not prime","$" ;16
msg7 db "Number is prime","$" ;17
msg8 db "2^N Is : ","$" ;18
msg9 db "Fact Number Is :","$" ;19
msg10 db 13,10,"Enter number between 1 to 8 :","$" ;20
msg11 db 13,10,"Enter number between 1 to 14 :","$" ;21
msg12 db 13,10,"Enter number:","$" ;22
;23
;24
one dw 1 ;25
two dw 2 ;26
three dw 3 ;27
fore dw 4 ;28
;29
number db 7 dup(?) ;30
;31
;32
;33
datasg ends ;34
;35
;36
;37
;38
codesg segment para 'code' ;39
;40
;--------------------------------------- ;41
;42
fact proc far ;43
cmp ax,1 ;44
jg L1 ;45
ret ;46
L1: push ax ;47
dec ax ;48
call fact ;49
pop cx ;50
mul cx ;51
ret ;52
fact endp ;53
;54
;--------------------------------------- ;55
;56
prime proc far ;57
;58
cbw ;59
mov bx,ax ;60
;61
mov cx,3 ;62
compare: ;63
div cx ;64
cmp dl,0 ;65
je notprime ;66
add cx,2 ;67
cmp cx,bx ;68
jae isprime ;69
jmp compare ;70
;71
notprime: ;72
output msg6 ;73
jmp exit ;74
;75
isprime: ;76
output msg7 ;77
;78
exit: ;79
call menu ;80
;81
prime endp ;82
;83
;--------------------------------------- ;84
;85
tavan proc far ;86
mov cx,ax ;87
mov ax,1 ;88
ta: ;89
mul bx ;90
loop ta ;91
output msg8 ;92
itoa number,ax ;93
output number ;94
tavan endp ;95
;96
;--------------------------------------- ;97
;98
menu proc far ;99
output msg1 ;100
output msg2 ;101
output msg3 ;102
output msg4 ;103
output msg5 ;104
menu endp ;105
;106
;--------------------------------------- ;107
;108
;109
;110
main proc far ;111
assume ss:stacksg;ds:datasg;cs:codesg ;112
mov ax,datasg ;113
mov ds,ax ;114
;115
call menu ;116
inputs number,7 ;117
atoi number ;118
;119
cmp ax,one ;120
je one1 ;121
cmp ax,two ;122
je two2 ;123
cmp ax,three ;124
je three3 ;125
cmp ax,fore ;126
je fore4 ;127
;128
;129
;130
one1: ;131
output msg10 ;132
inputs number,7 ;133
atoi number ;134
cmp ax,8 ;135
jg one1 ;136
mov cx,ax ;137
call fact ;138
output msg9 ;139
itoa number,ax ;140
output number ;141
call menu ;142
two2: ;143
output msg11 ;144
inputs number,7 ;145
atoi number ;145
cmp ax,14 ;147
jg two2 ;148
call tavan ;149
call menu ;150
three3: ;151
output msg12 ;152
inputs number,7 ;153
atoi number ;154
mov bx,2 ;155
call prime ;156
call menu ;157
fore4: ;158
mov ax,4c00h ;159
int 21h ;160
;161
;162
;163
;164
;165
main endp ;166
codesg ends ;167
end main