|
发表于 2012-6-1 12:38:44
|
显示全部楼层
我看了一星期小甲鱼关于王爽汇编的视频做出了课程设计,代码如下,哈哈好好学吧
: o: P) s7 @% M- m& { Yenter macro
! r4 p. B6 t/ A6 t push dx
5 Y* m* G' o; S4 Y3 W push ax* v* M; J" J# `1 K6 S+ ]' D) V5 `4 p5 F
mov dl,0ah
7 s1 o4 F( O( d4 |5 Q% r& H mov ah,2# h) F! E1 Q. \6 ~6 ]0 l
int 21h
' y& Y: `# b2 _& h& M( Y mov dl,0dh
1 \. _+ y" N( V2 T6 y$ a mov ah,2
* U2 y4 r$ A% Z. L. b' w int 21h
3 J/ W ^3 x# W, g pop ax
: b3 a3 L7 Z( u1 s6 p pop dx
$ k$ r7 o2 A2 Sendm) F3 _1 F. Q' J! b b$ ^
" s L$ E( |* K' U# b/ c
assume cs:code,ds:data T5 n" O# c& Q' Z. e
data segment
! w/ ?8 C$ ~4 w) u1 v' Htable db 300 dup(0)
1 q- r! e7 C* t9 {# g( Z! H' lpro1 db 13,10,'_________________________________________________',13,10# |0 L/ l. t; u
db 'no more than 20 characters English name.',13,10
$ L( D1 o9 z1 e1 u. Q( o db 'For example:',0ah,0dh,'liang xin hui',13,10
" q' [7 j7 r' |# i; { db 'XXX',13,10,'XXX',13,10,'......',13,10,'...',13,10
. Z! f/ p+ a: D7 v db '.................................................',13,10; n1 b+ Z; a7 D3 A/ p0 A6 x |5 F. {
db 'Please input:',13,10,'$'
, k% O# }4 u. N6 l5 d: ^1 i. [; Ypro2 db '.................................................',13,10
@; e9 X v7 W6 C; F db 'The results are as follows:','$'
/ V8 K& s4 i# ~! v/ X
4 R3 @. S2 p; L; G/ I. s, ?cont db '________________________________________________',13,10
+ H% d4 S+ q' j8 i2 q& [ db 'Can You Continue(Y/N):','$'
6 G" @) u$ X j# f/ o
+ w5 [( h8 V1 p- xcp dd 50 dup(0)
) o6 D- k1 D- }9 R; ~data ends4 b, t8 t- E8 ~$ `2 |7 T
2 E) h. M6 Y0 S8 j0 X7 Ecode segment
( C2 |6 [6 V7 H+ Pstart : mov ax,data
U2 o7 u$ \$ U! L& B/ ]' k mov ds,ax) I- @% W' \/ o2 ~7 x0 g z
call prop1 L) x5 j! ]# j- B9 H f/ @
mov bx,offset table
$ [+ v9 C; U6 ^3 c) U8 J% W mov si,08 Y! x0 C6 p, w! n5 I# |( ]
mov di,0
0 E/ }2 F! X6 v1 H5 c
, z, ]; s2 e5 i6 m9 H6 b0 {% C+ @
- V7 U/ ?4 T/ T+ E7 B9 k$ K call enterchar
4 f' n: p& U6 V( P1 Z8 Rperp: - p, A3 s, ^9 G7 a8 _6 Y
dec si
% I1 ~- a3 B9 l" g" I# x mov dx,si' [9 `7 `2 t: X( q
inc si
8 ?& O8 {& T0 U mov cx,si8 H! g- s+ U" Z6 H: L: E& t1 l1 v
call arrange
! G0 A7 \& K* w$ l$ ~7 b* m call prop2
: O5 X0 b$ |* h call putchar. z" f; a* w3 a' ?6 P _5 J8 s9 I
liang:4 q! `- E! U- _( Y. O- {# [
call Continue0 b" Y1 d! s6 q3 c" D
call judge3 l( u+ W# b; F) y2 D( k; _( L
mov ax,4c00h4 a3 s8 x( a! z v0 B- I4 N+ H* r
int 21h
u# s& a! @' w( T. z4 ]( ?4 V, N) |7 y0 g4 k0 L+ m) }# H& n
* e, S$ `& S8 K4 ~" n+ i4 a
Continue: enter# ]7 D: `) D% ]( P8 H" j
mov dx,offset cont9 M5 C: ? ]7 F
mov ah,9h
$ O! I& _5 p: `" ^$ k+ c4 \ int 21h& h2 F* U9 F+ E9 W! J# U' Y% b
ret
/ f0 d! N. Y5 K
+ |6 Y! O+ L! H& I' }judge: mov ah,15 L- Z* a# \( D& W+ z3 g) C6 P/ V
int 21h
9 G5 Y G1 n: R: R/ G or al,100000b
: U9 c2 I; m. j/ M, V ? cmp al,79h
0 x' B# H! ]) w+ O) r$ `# Q: `2 L: p, ` je clear8 h6 L S, _" \* L! K
cmp al,6eh
$ y" V* s7 F4 a( W T- x6 w je endj% r `5 I, j/ [5 m7 N
jmp liang ?( f# k/ z4 N; M
endj: ret
+ w5 E4 N# c3 R( I5 f0 _6 t ]/ n0 u# i1 o8 \6 ^$ ?- ]& B
clear: mov bx,offset table/ r6 {& E0 E& u+ e4 h0 @9 ^: N
mov cx,3009 O* A4 \1 E' d5 j& a3 T+ I
zero: mov byte ptr [bx],00 _ U+ g6 X' x0 H
inc bx, `! K$ X0 e! x) ~) U. |
loop zero+ H1 f, C& k8 m' Q
jmp start& G* E6 x6 N( A% U3 z4 R6 f
6 t" v5 Z1 v4 v2 ]; `* l6 I# ~9 R+ E1 A& ^- w
enterchar: mov ah,1% W7 H7 c9 q9 G% E$ C+ ?
int 21h9 Q! D+ j6 s% `( E$ K
mov byte ptr [bx],al
" T0 m4 T( P" M- A$ C7 L cmp al,13
5 \8 G; I/ D3 N" S0 ~0 v7 v1 } je endchar . ]7 @( k4 C% ]- I0 t
mov di,1) n- M. M& g( v7 a
inc bx( M4 b! e* U5 j- G
jmp enterchar
6 G9 |) C. j* F. I9 f+ c! d5 d6 i" N2 C0 C' p* b
endchar: enter I9 r' X) [- d7 A( j7 V3 P
mov byte ptr [bx],' '
& p& S1 E6 f( e2 }5 u) \( K0 k1 E cmp di,0
, z: y0 X$ e! O6 l; z* R- v' m( { je perp8 B0 T7 {/ ^4 O8 ^
inc si
+ g. x5 V5 {" ] O# [ mov ax,si
/ Y- Q ~9 } u mov dx,21% v9 g- P+ q# s d
mul dx
) R: ]) w; O( ~7 G6 U3 ] mov di,0
# i7 G- ~/ ~" K3 ^ mov bx,ax
! y K. H! A. Y1 y8 O4 a jmp enterchar
8 R! W" B* l, V+ C8 a+ m& J0 h8 A- @8 A7 H! V4 e) }
arrange: push si" i6 w4 |6 g6 T" J B) w
push cx 8 j% Y" ]6 e* Z: E
mov cx,dx
1 J) q N9 i4 W: v mov si,0- j( S7 U- o9 i$ r7 n
mov di,21
) v# l( X+ z7 D9 Z! s: e4 _+ f/ O* i- R* ?4 d" z
s1: push cx0 v8 e' C2 Z H, c
mov bx,08 t! [6 s2 s: e
mov cx,20* f* c0 U2 f w8 Y
ss1: mov al,table[si+bx]
) N3 P' `3 Q# l J cmp al, table[di+bx]7 g7 k+ S4 w1 `
ja jiao# b) a8 o, { ~7 @% k) t# a: N
jb s21 k, ~4 ^% h0 V3 B- s! o
inc bx0 { i# ?0 P/ H2 M( V9 H. b; _% q
loop ss10 m9 `5 C! Y& K' y
jmp s2" Z A. l/ F& y$ @4 q8 |
& J/ z; h' M( q: k) w O5 P5 o
jiao: mov bx,0
8 i9 o& J& G8 o mov cx,20# G* w& J A5 ?% c+ q: [' {4 Q2 D
jiao1: mov al,table[si+bx]. X; B8 j$ t$ a8 |% o- Z5 h! {
xchg al,table[di+bx]) b* f' r2 w. \4 p: N4 M
mov table[si+bx],al( r; E6 F9 B% B# j1 ^9 f1 }
inc bx
' _* I# [3 e. n% A5 x! A loop jiao1
' G- X$ Q! F- k1 T7 W% w- }+ f9 K7 y& `+ ^ }: S! J( e
s2: add si,21 E9 Q9 e% @) Q0 H( U9 A
add di,21
8 v# d* Y2 ]+ `/ n, s9 D2 m7 { pop cx
6 o# x- @+ W+ o7 w5 e loop s1 t. t |( f& S: J
/ z3 I) J4 W1 ~) ]9 X' x! s
pop cx' [8 Q7 |- G" U9 D
pop si
+ w6 ^3 u2 Z: G' |/ L4 _ loop arrange
- n0 S. ^3 d" h1 x, k, V ret
' O! l5 R% C; D5 K! _+ }7 _8 e9 U( ]* \& }7 N
putchar: mov bx,0
+ [: d! R- B' z @5 u! H8 _) J# A mov di,14 O3 X# U# `; v8 O
, e! F3 y2 O! f) t
) X% U ?7 Z1 a mov cx,si
; d; Z9 a6 M" L$ Qput1: push cx6 } h$ q( y7 V1 v, t q0 N, t1 Y3 ]2 z3 l
push bx1 w; ]5 @4 x( r( \2 }
6 r( d! x8 M# B2 C' v& d5 N enter
6 K( ^- l1 B9 L- r0 l
8 z1 ]% N% S& s- p4 L& e mov bl,10% S- H3 ~' m9 A# o
mov ax,di V! J) F: [; G- w3 F4 F- M$ a
div bl. B9 m: Q6 b5 _* t8 h- @
mov bh,ah! S" ^! J5 w% I- i( M
add bh,30h
3 P/ V. E" O1 B! z7 l$ I9 A add al,30h
" j) m% s* A+ K( g
2 R6 V( K/ v6 j* M7 Q& W# n: u mov dl,al
H1 Y" [9 [4 B k3 J mov ah,2/ m3 Q0 g- Z; d# m" o3 Y. s8 u" s
int 21h7 b$ n/ q4 R# G t! w8 y. F
mov dl,bh$ D8 m, I; w# h" |
mov ah,2
: R* `( F& r) V' Y }1 U4 r int 21h
% h- f- Q3 D; i% f' w+ }5 K+ p mov dl,3ah8 Y% r+ p; E( {
mov ah,25 z2 L2 k, @3 E A
int 21h/ q7 @7 i# c& g7 A6 |$ g6 t( Q
pop bx 2 m0 \9 f. ?+ H- v
mov cx,20
t" i9 q( ^+ @1 K! M push bx( C, }# F: u8 C) J
put2:
. M# _, i, M2 t2 y- d) ~. T mov dl,table[bx]' b. |9 Y, l9 e, f; Q
mov ah,2h- Y0 L5 t0 v; j+ \$ ]
int 21h# |2 ~+ P7 @1 h) @
4 Y& ~( _. C r) L, A
inc bx
- x& h0 @; d& q( G0 i& ?/ ^) p loop put2 o. n8 J6 G% G) E" x. L+ H
inc di
* }+ e) @! f' w* c* c pop bx1 x7 i( P, u$ G5 I3 t9 z2 p
add bx,21
4 Q& s5 i* N- C% M, \2 v* J pop cx2 X& u. i% e+ S9 g: P8 @ P: L9 L. |
; `0 C$ `$ V! j% [* S loop put1
. }3 i; V7 s( i9 w# |6 i ret! U6 O% M, O9 T- \( m
% K- o) Z% }4 m! V" tprop1:
% k0 A* ~# z! R( A( L {% s) O mov dx,offset pro1, S/ E+ a4 q4 O6 W0 `8 w8 Q
mov ah,9h( Y2 q+ D# B) ]; c
int 21h
! ?/ R" e1 n4 A: k4 M5 o, x( \! \4 R enter 3 S, a2 s$ _6 m2 b+ O% l! ?
ret
/ {0 l% A' l7 u# e- A3 N$ E8 T" r- Z+ H! r& G
prop2: enter' V1 V3 ]3 O" N" ?' ?- ?/ U
mov dx,offset pro2
1 x0 v$ E" D: f4 t- T mov ah,9h
& G- m& E) O' t8 ?8 t- ?0 _ int 21h9 S# P( X, g9 B0 e1 n) k
ret
3 Y0 t, P7 x' f5 o! ~' r2 k
0 H' u) J$ W% p! |code ends
. m4 i i+ M7 J) o0 \8 {% B3 h+ a8 i1 iend start
6 D6 g# ]8 X+ M+ r
9 n. u; C/ v- r h# g+ x) R& m3 e0 c; T& Q; K. |
|
|