|
发表于 2012-6-1 12:38:44
|
显示全部楼层
我看了一星期小甲鱼关于王爽汇编的视频做出了课程设计,代码如下,哈哈好好学吧1 N1 X) K3 B8 t; P0 L' J) T
enter macro* _1 h, a# W, K, S$ y& h5 ^- \+ I) e
push dx
$ {" x3 d/ a1 g( S8 k- | a$ G1 d push ax- g) G+ ]& K& A5 S, H/ N
mov dl,0ah
& t1 g5 u* a! T+ b mov ah,2
, ~4 m( |6 k& C ?% D; U K int 21h8 s; G& m; |- {+ x6 }5 Z& j
mov dl,0dh
j/ V5 D" N& ^. P mov ah,2
( w; x+ s. D% d# w# q int 21h
7 ^1 O! G$ |% b pop ax o3 ^8 c5 O5 z, K; C; _
pop dx
7 |/ p' |5 Z0 A! N/ iendm
+ E' P# E& q" f
4 y4 `$ C% p3 U4 z Aassume cs:code,ds:data
( e, A0 H/ d2 xdata segment
. v6 w3 z7 k5 F' ctable db 300 dup(0)/ ~% [& E/ Z6 s
pro1 db 13,10,'_________________________________________________',13,10
) t. @2 N" T7 y* A0 {1 E/ X& f db 'no more than 20 characters English name.',13,10; P, h3 O8 @- I" K0 @# \2 _% z
db 'For example:',0ah,0dh,'liang xin hui',13,103 I4 Y5 V: T9 k; V& l& i6 h9 ^
db 'XXX',13,10,'XXX',13,10,'......',13,10,'...',13,10. i4 U) i' l$ B( u; d$ q
db '.................................................',13,10
2 M: A9 _4 O# s, {- p db 'Please input:',13,10,'$'9 c* V5 |& N7 \
pro2 db '.................................................',13,10
5 ~1 {! V- {# n" v0 F db 'The results are as follows:','$'
' w- b" D3 I! @( m2 K1 m( k3 h. o- r! }7 X+ s
cont db '________________________________________________',13,10
U$ _* A9 y- e n# ` db 'Can You Continue(Y/N):','$'. V3 r4 f3 C5 F) s4 b) @7 v. f* L
5 y2 |9 W/ h9 k* a1 l5 Scp dd 50 dup(0)
0 K9 x5 m. }4 Y/ H% Wdata ends% P( {0 Q8 T' n, ]5 Q1 f
$ K# o+ H' X2 lcode segment
) {$ ~ C, C) E; Dstart : mov ax,data
2 M) b4 R) x4 d! b, M& V mov ds,ax
2 I2 n3 `: x+ @% q0 O9 _4 O call prop1
^4 m6 W& W$ e$ Z, l mov bx,offset table
8 r1 N' [$ Z+ e7 w8 n mov si,08 q: P* k4 V3 x4 t$ V' A( A1 Q
mov di,0& G/ [/ j% X: |) q1 x8 c8 l: g
' e- l4 y: B: X# g5 o0 R6 I
7 T0 z1 U' _( `. s
call enterchar6 M) w( c7 n- B. O% Z' W, }" R
perp:
5 Y/ t& e% b9 N, {* ]/ B9 \ dec si
8 }) N9 r. N$ e; V3 Q mov dx,si
" N8 k# q. |! s* A inc si - g* C( [: k: j/ a# {
mov cx,si
9 U0 ]8 Y$ g% }1 C call arrange: o) u* c( `4 Z4 v& p
call prop2
- x6 p* Y/ I+ |+ K1 X" a/ V call putchar
) o/ m6 V1 t2 x% y, r9 Gliang:, y f C3 G4 |) c( Y* x V
call Continue
8 \: i5 a4 \3 z. E$ [3 e6 t4 t; b call judge) k) P( ~, V1 Y t
mov ax,4c00h, X7 a4 b# I* \2 ~9 v5 o6 o
int 21h8 S; M4 D# e+ e6 F! R
2 _: V6 T: n8 ^# ]" I
2 `3 k/ m* W' z! ? A, ^! z
Continue: enter
( G3 X% T0 u+ r2 \# C {" J" ^ mov dx,offset cont
6 f/ E7 ^& K u: K$ d mov ah,9h7 D) B/ q2 P# M# T* i8 P
int 21h
# U& h( P( L* L6 z' \8 q2 _ ret
* ^+ G1 N( n+ P' L$ |3 m
2 ]! b% ^4 f6 j$ ?5 Cjudge: mov ah,1+ @7 M3 H4 |) j3 S) P$ l
int 21h- u- ~- b* U3 P) B
or al,100000b
1 S, e* v G1 }4 F- m cmp al,79h
2 y* S1 ]: f- d) q je clear
7 k9 ^% o1 u- U( I% l+ E3 _! a$ X3 }% u" h cmp al,6eh
# K. [6 p- i4 l' b5 P je endj9 Q k. @/ w8 L1 L, o
jmp liang0 _& J) o4 D. a
endj: ret + m; P# h5 O7 H' n
0 v: W+ [4 m4 H2 Yclear: mov bx,offset table; U7 k3 K# {! s% u! x3 k( }; ^
mov cx,300
0 Z4 W b# S. jzero: mov byte ptr [bx],02 l9 I& k/ @6 G4 A n& }& C
inc bx
Z6 o; ^( `' n E5 i/ k loop zero; H5 K3 T+ N. g& g* i# j1 o5 q) L
jmp start
/ }+ V1 R; d6 l1 j1 K7 q: a: [; Z+ s8 s/ |& ?* \1 `; R- _
* Y6 q0 O+ b6 m+ N3 t/ P: Q% k
enterchar: mov ah,1
& _4 r4 i* `" x3 Q+ {$ |+ k0 B6 L int 21h
( r, B3 S, q8 ^. h. j mov byte ptr [bx],al
! p, \" n3 E1 Q/ F9 T cmp al,13, C8 }: Y( r8 l S3 _0 l
je endchar
4 i; _8 a5 c% t mov di,1
; F# u" P% U8 e/ a inc bx$ y3 Q5 h1 w9 i. y$ X' T
jmp enterchar9 S+ ]& k( F: g! v
' |" V5 L* t& v( u4 W4 Y7 W( h! \endchar: enter ! k8 b( c1 s) H6 n9 Y* k4 X2 r {
mov byte ptr [bx],' '9 h5 ^3 j1 k% d1 B
cmp di,0! Z+ V. ~& g3 z/ x
je perp
* w. o! A4 N- b/ | inc si; S6 C" U+ v/ ~+ ?
mov ax,si2 z1 V" @" p$ ]( F
mov dx,21
, n6 M! n9 d3 |1 T" S9 } mul dx3 B8 b* N/ S5 M% G* f
mov di,0( ? A j* e1 D6 {1 ~
mov bx,ax . X" ^2 y+ O2 Z9 e
jmp enterchar) l# ?+ l. Z" e: H, w
9 q: U; T( N' P5 \( `7 x6 c
arrange: push si
A6 ]/ a2 n* d: e4 ` push cx
- V" i5 y1 ?& ` mov cx,dx
5 |7 g ^ b, D9 q5 H% _6 }, D mov si,0! o: r9 p2 Y! S ]/ r7 K
mov di,21; Y) m4 G+ V; a0 g: D6 M/ T u
' W B( S$ n! `+ W8 p$ m* |% M. F4 ps1: push cx9 M4 G1 ?$ g$ e1 w' Z
mov bx,00 s3 V0 M5 p2 d4 Q9 X7 h) x; ^
mov cx,20& e8 d5 o% d1 N4 S' |
ss1: mov al,table[si+bx]
: e/ u% O7 M1 z/ i" C cmp al, table[di+bx] E/ D+ r& C0 Y2 J- @, F3 f
ja jiao
) t3 ]' p, L+ h* A( A' G$ k3 e. Q jb s2
5 [9 V) G! ^3 `9 A) w inc bx
6 S, z2 E8 e/ |9 P* H loop ss1/ d2 t' P5 O8 g& { n
jmp s2/ l1 ~! u3 W" G
6 Q/ H( |: ?- U3 Y
jiao: mov bx,06 A6 `1 F( r8 P* a
mov cx,20- |' e) ]/ d7 f" s
jiao1: mov al,table[si+bx]+ u! P( ~7 ]) P( N2 k3 h+ G
xchg al,table[di+bx]
+ T/ S9 \/ W2 _, X. l ]- P( d mov table[si+bx],al
) @+ ~& o, G0 v; n0 ~ inc bx% v2 M8 a4 L) }0 H- b0 C
loop jiao1
. p! G# P. c4 i3 R8 }
8 x N3 [/ N- u: Js2: add si,21- J9 W" @8 }! E: `& I; s3 |
add di,21
) F( }+ w9 F B+ c* y- H pop cx+ P7 V3 p+ a; h9 H: v2 u7 c
loop s1
7 m% W+ [' G# s/ V8 t4 M R6 I2 u9 Q' V# Q
pop cx
2 E) o7 ?. g' I7 Y pop si" r1 `+ [2 `# \" H3 J" @
loop arrange+ e1 h& M+ j9 x1 m
ret/ a: d/ T5 p6 }; @# H$ r- B
% d, G, B& o9 M/ b" q' zputchar: mov bx,0. _$ [2 R" e% p, @: R2 z$ R1 d {: y
mov di,1
) o, m# }- o4 @$ x
1 s b5 k/ j' q/ c 0 v9 h9 m% o& @2 F
mov cx,si
6 |& g9 n# g. W! l: _6 [put1: push cx
1 R `; u( D5 [( L push bx" Q* r% z1 A- u5 j
% |( h4 z% X! P4 _ enter4 y8 I F8 l! ?$ e _
, r. Y% v& k# t m# e
mov bl,10% ]" ^& v' B* l- M. S0 _" Q8 k7 W% u
mov ax,di! t; H' r o* [- [" _/ B3 I) o
div bl
* I- z1 u( j3 L3 ]3 m mov bh,ah8 i3 ]# B% U/ {& A
add bh,30h
8 ?: H: f T1 m1 S' F% X9 { add al,30h
1 N! U g/ r" f8 m2 Q ( |; v+ b) `5 e' I. U( R
mov dl,al/ G; o0 Y# |4 @
mov ah,2! i* v9 ]. }9 e9 Z# m7 b
int 21h( ]- f# Z0 ~% v
mov dl,bh
3 }' e& c- X; u: c" r8 P mov ah,24 Q3 m) V \/ g
int 21h
# B0 i6 f) b ^6 e/ [6 _: z @ mov dl,3ah
; D. Q. k/ a) W# O mov ah,2 R! s! `& p& ^9 }
int 21h0 K, X# n( n5 d7 c+ [8 B/ u6 m' ?& u
pop bx
6 V* _& c+ r* ]- o$ B: p$ J mov cx,20' I3 @: P1 H: x
push bx
, `" ^6 a' w; K! N+ A* _0 q& Jput2:
" ~2 o5 d: [0 X% x mov dl,table[bx]& h. B- |& p; p* ?6 }' x6 l
mov ah,2h ^2 q$ x! @$ v- \9 ~
int 21h) L$ Q( Z" y/ ?
, v( ]+ C# y: _2 j" X: K3 g* K
inc bx" I, F4 j) n2 b- A& [# s
loop put2
) L0 w$ |6 y2 D0 R9 f5 e. ?( s: Z inc di
3 c) N5 a' u+ U9 C pop bx1 Z3 r: {) L& z5 W' [( P2 J$ M* ^( ]
add bx,21" |# V+ ~! h' Z+ P1 z# P* m
pop cx0 b5 a3 Q- Y t. n7 J
' _6 E9 t- ]2 b+ C7 z loop put1' Q; @4 t6 p& P7 c
ret6 t( V( V9 `9 X
5 x7 c- T, V+ t: r
prop1:
. @& A% j2 h# A; ]: ] mov dx,offset pro13 k1 `# w& Z$ d
mov ah,9h
: q3 R8 O$ C* u int 21h
7 ?8 X z+ l, E4 P0 ?: c4 s# B enter $ g& u+ ]* d8 @( L
ret4 f6 c7 w) E @. s Y, s. N
- ~; x8 q/ v# L& H$ |. sprop2: enter. X# _+ \$ n5 E+ R0 Z* b
mov dx,offset pro22 { l" `0 b- w1 w& }
mov ah,9h
8 s: T$ h. i" r( {2 B) B/ n! o' e int 21h
! Z/ A( P# P1 N3 D ret% l. E# q: @1 c$ H. f
0 `1 f6 L) P/ @( }5 ~
code ends
! G- f6 y8 }+ P' Hend start! d7 b3 l' N) _, |+ m
u5 w* k& A, q
" S4 a& l1 @! Z, q; k% j6 g |
|