|
发表于 2012-6-1 12:38:44
|
显示全部楼层
我看了一星期小甲鱼关于王爽汇编的视频做出了课程设计,代码如下,哈哈好好学吧8 ?# b9 z$ W7 `9 T6 M; n
enter macro3 ^ ?. s* D: s; M. R4 Z$ @
push dx
& I. B' H f9 {9 I push ax# N" @5 G& J% e3 W0 g6 I; W, r5 K
mov dl,0ah* j' E' b* ~* P
mov ah,2
4 x0 J; W9 o U! _) i int 21h6 G0 B+ j+ d) U0 i0 k. k
mov dl,0dh) o0 I* d/ [6 Q1 h2 k |( I4 f
mov ah,2
! H q- y6 q9 Z! l9 V int 21h, j+ w; Q! p ?6 ]9 @
pop ax7 u8 a) s! c9 a
pop dx
6 L+ G0 B7 B& @4 O- f! Bendm
; T1 K0 p: f1 m7 q/ b
! n1 m. a7 s0 hassume cs:code,ds:data2 s, q: X) k! w/ \: \
data segment6 u/ a- Z3 j, Q+ Q, Q m) n
table db 300 dup(0)
$ G% p# f+ {$ v4 c* P7 fpro1 db 13,10,'_________________________________________________',13,10- G! \# f8 o1 a {+ g% A
db 'no more than 20 characters English name.',13,10
, P1 N: i- j5 q6 x) V5 r db 'For example:',0ah,0dh,'liang xin hui',13,10
5 V t. T6 N/ ? db 'XXX',13,10,'XXX',13,10,'......',13,10,'...',13,10
: O B% k/ o& X3 N# _5 l db '.................................................',13,108 t# P, p: H& _* u) ?' S9 s
db 'Please input:',13,10,'$'2 D( }0 v' s4 _8 E3 ~ u
pro2 db '.................................................',13,10 j* b6 Y, S& C5 D
db 'The results are as follows:','$'& r( Q. ]) C) n2 A8 ]6 U0 ]2 o! |
- ?3 J/ J2 w( Y! ^. r0 {cont db '________________________________________________',13,10
% q, d! R8 r S: p0 e4 ^. u db 'Can You Continue(Y/N):','$'/ w3 u' J* a# C
( {+ p& D4 T( z9 m& B8 q6 U7 V
cp dd 50 dup(0)
; _/ F3 z" ^; z3 ?( C" H$ udata ends+ u* I8 D% y& p
! ?3 Q% \2 j1 m
code segment
7 D+ O; E! X( d! T3 rstart : mov ax,data
( n( U0 o6 H. ?5 e( h" V. I9 }$ G- t mov ds,ax
3 _4 T) F# ]) [ call prop1
3 U5 ^7 O) D4 i3 X( b$ c mov bx,offset table
3 B4 W0 T4 _ F- D" E. `' A5 c+ F mov si,0# s% ^) [1 n5 B& o- G+ n
mov di,0
! M9 O9 C: _* Z) W8 w3 v & r X! e2 T9 | i# t% R1 R$ |
4 c9 \3 D* N/ r/ A, r1 }& b6 u% s call enterchar, R- a& Q" h) g8 I( b3 F. ]. l
perp: , }1 y; ]7 W( \" Y, `& r2 o/ k
dec si
* o3 z0 W& h& g2 Y mov dx,si& ~5 C w5 Q. U. Y R( }4 ^# {
inc si
" N! U; T2 r# Q( D mov cx,si
+ w, G! t) V" f: q+ s call arrange- R& d p5 z' k: T
call prop24 J, r* Q& j4 P1 o% r Z
call putchar4 W& s8 t( P9 T7 J6 B/ E/ v
liang:6 Z; I! S9 ~, I2 S5 v' R [5 o/ S
call Continue
# Z2 y, x6 h4 z8 }, x4 t' w call judge3 v$ m, E! I8 L/ H1 Z, w* y
mov ax,4c00h: p" I5 ?( {: W! Y' t# D2 U$ a
int 21h
6 \# F* }+ s9 q Y& j# v4 [8 ~! L! B) e3 d, i9 D
; }& l: f: V* {# F& g3 _ r" G7 XContinue: enter
2 L5 [- E! ~" J" K' f mov dx,offset cont
! n: Z: ]. s' Q6 D* a mov ah,9h9 M1 R1 u' b0 k
int 21h" z. |" V- G2 C2 A$ L" N1 l
ret
9 ] H8 ^. u n3 I' v1 p; j' @ G9 y$ l0 T9 F; z
judge: mov ah,16 J5 {. D2 z+ c) x$ Q
int 21h: f7 [5 q+ Z( Q3 p& O4 J/ n5 Z" O/ ~; Y
or al,100000b! b$ I4 a& @8 g! R* Q( x- b" W* b/ M
cmp al,79h
0 N/ P8 ]1 y+ v c je clear! l5 ^6 V6 C$ P/ F3 u3 i7 ^4 |
cmp al,6eh
7 I! h, `" A) f* Z/ d4 [% I je endj
7 C) N0 x" e; V jmp liang
: m& @3 M4 K+ g/ c6 t- C Iendj: ret
: x3 ]6 p: k8 s$ j+ n4 {, S
) k7 y" V8 D. v# m" b! Dclear: mov bx,offset table
9 k8 D# b; u, x2 i2 P) s; p' p: c/ u mov cx,300
: {- }, k/ y0 H' y8 dzero: mov byte ptr [bx],08 K8 v$ a: `5 e1 N
inc bx6 |8 N8 C' s* q* _3 E f l. G
loop zero
% k! A0 m; ~6 ~ jmp start7 i; l; p! {" o
& w; H% @' h+ p1 I# `' P5 v& c! I! N) b
enterchar: mov ah,1, y$ X, Z# R- @* b8 h# V+ b
int 21h3 L0 c& n( {8 C! e: l* O
mov byte ptr [bx],al
8 l8 O* m7 Y/ q1 B1 B( |2 ?& J5 R; R cmp al,13/ W% [% u) m5 E4 v3 d7 H9 y# F+ l
je endchar 1 T2 v# b! @' j3 g# ?3 X/ j
mov di,11 K, h0 X, p; l u4 e
inc bx: v+ }8 A0 \" Z# f: N
jmp enterchar
0 W# e+ ?5 u6 _
% F7 L% {+ d: Y/ s# Hendchar: enter
, ]' m6 @( J7 z! `" f% W+ ? mov byte ptr [bx],' '
# I" \+ D9 Y, H# ] cmp di,0
' C2 y" K( B) K: g) P& Z je perp! T2 K2 Q! {3 H' _ n0 ?- J
inc si! U6 J" J: s9 g5 y3 y: V+ p
mov ax,si
& }% V3 `* }, B) ^% `1 z) }7 N mov dx,21- @# f2 E/ B; @( y, I
mul dx
' Z; \* @/ @5 D- Y: B mov di,06 v2 d" V, p \' p
mov bx,ax
% v |; R' A1 S jmp enterchar
4 P+ g7 t6 {4 }- x- ^! ]; ?. e- r* l/ g+ A2 }
arrange: push si, [- x1 o2 h( c5 R
push cx 6 V. \: \! @6 W1 U
mov cx,dx
/ J" h" t1 O, m) h2 ]* p( h mov si,0
) r; b+ M( l+ Q mov di,21$ |( g4 h& n: a& D8 N, t h
. J) A/ D. Q3 w7 P( ks1: push cx) W# f ]! c+ ^' J/ m8 e
mov bx,0& R- |. o: ^8 U% H/ B3 S
mov cx,20
, d9 C/ F6 W$ q* X. Dss1: mov al,table[si+bx]9 o" G) Z. j6 Z1 {6 w
cmp al, table[di+bx]2 t! S( W- B: C" w' I
ja jiao# j5 A0 ^2 N; p$ ~6 s
jb s2. x! B9 {- V" C+ ]( Y9 Q, l$ p
inc bx
: S* e, j$ D0 }1 y: e Z1 U) [ loop ss1
$ r7 ?% {( B( q* P) O. E jmp s2
8 U6 a" l% g3 a4 o2 v7 m9 h& q* u/ k/ h2 h4 G7 b7 }2 j- v
jiao: mov bx,01 L0 r6 ?; {" f% B" H; q# }- r. Y
mov cx,20% V _ v$ ^+ o) _7 s; `
jiao1: mov al,table[si+bx]! ]" l: i \! N
xchg al,table[di+bx]3 v& }1 h$ z1 Z# z4 Q6 T7 ~
mov table[si+bx],al
% d9 D& s* z1 b* H0 E; c% A9 v. { inc bx
# N, H, `8 u* E% f$ P* ~ loop jiao1: W# v8 z$ f, m8 t# W2 J
) t e6 D; V6 R. T3 D [
s2: add si,217 w9 |/ C! O5 P$ G. H6 n" I: w
add di,21
8 i6 Y' {6 |. ?: E pop cx6 `' ?/ t. ?) K' {
loop s15 p! i5 H5 c7 i& N7 k
/ [0 F6 P# \/ w& d9 {! I# j4 @ pop cx
+ p+ {! `' c; @/ j pop si# A7 U2 t \$ P5 [4 T _* H* U
loop arrange
! d' `$ b* h& V- Q$ G# w+ L ret
) G4 w/ w/ i# W2 X# p1 N4 E/ C
- \* e5 l: q' [/ \8 Yputchar: mov bx,0
2 x; a, e7 z) ^! B- i mov di,1
' n, o8 |' z5 b: k2 J$ x 6 _& x: _0 a8 Y3 e* d v
5 W) C: e% p' k: R mov cx,si
% x$ d+ x" ?+ u3 \! p& wput1: push cx. }9 A, K( l7 ~
push bx
0 F" p# S- A; N& n) ^7 [0 X " [+ e3 ^6 U4 U6 \) O4 C
enter
6 I6 r" K9 W6 m1 w# h( T7 g9 c
( X( i3 J4 j6 l8 E- F mov bl,10: z/ ~9 x4 R6 H5 y- Y& }1 i, i
mov ax,di3 W, v. K* _' P" L4 i' M N
div bl2 e6 @* u( a) i" y* e8 U$ p% E
mov bh,ah& R; g& P- _; b* Y+ {
add bh,30h
: N1 M7 o$ e, k add al,30h* c R2 @- S1 C! I
) j3 L$ b9 q0 [* Q mov dl,al
. J# Q0 q, w9 @* O! E mov ah,2& x: A$ X v& F3 I' A9 i6 @! g
int 21h$ z, u! b, K% i; s, `3 |
mov dl,bh
$ _# Y' o- P' {' k- u; q mov ah,2
5 v @3 K. [1 U8 P4 Z int 21h
- i G/ W7 r" p3 | mov dl,3ah$ d! B( A1 q3 y* V3 t h
mov ah,2
: B2 {% ]6 J" J3 O! F% ^ int 21h) C, l# G7 K+ `6 j) I8 O6 h
pop bx 8 O. P8 A+ y, a8 w" j2 {: x
mov cx,20# Q1 M3 f( q, L( S
push bx
4 k, ]# u" @9 ?& q# w3 J, ^put2: $ A, c- R4 S+ [7 h! \5 z1 D
mov dl,table[bx]' E9 n0 A9 h' X- q$ a t- Z
mov ah,2h7 q9 K* _9 C# S& u0 r6 I$ R
int 21h7 }2 I1 N7 @7 V
8 f+ O& w4 y' z/ r2 e' Q# v, v
inc bx
' q1 z4 b& k% I loop put2
' Y2 N% c4 F' s2 C inc di & n. S; Z L; _- M# R* z, S
pop bx/ l l. K1 [0 Q0 d* s" R
add bx,21: t) `9 w/ X# p5 [3 x" m# P1 a
pop cx
g. \7 Y, W: B; Y $ ^# H4 W7 n/ A7 [2 T: E& ]/ P5 B9 X
loop put1! z( q+ D( }! X) G% b3 _ I% d, E
ret( [" G2 ?& o0 F$ w/ f/ E' A" t! i
9 A8 R! @6 X/ j
prop1: , f& f; y) F M
mov dx,offset pro1
4 f. a* [* h5 L$ }" n: X mov ah,9h
6 o# r7 A9 B% W4 v; @ int 21h
; D2 J# H/ U0 X8 W0 g* l' |0 G: Q enter 6 D- ]" @9 ]+ h. v
ret
3 }2 F" t, G2 D2 q; N5 Z3 d# l j' f0 P% ^: y0 \! [! |$ u9 X. d8 H
prop2: enter% y$ G0 [6 W- v+ E* y
mov dx,offset pro2
! u: X0 F8 v9 a# ]/ o/ R$ m mov ah,9h |2 ^+ P6 G1 f- A
int 21h
1 J; _& r$ m/ q! V3 l9 ^ h3 J ret
2 b8 f1 T0 @: K5 ]+ m6 h. V: c9 o
code ends- t. i4 N! R0 L* Z5 E* R- W6 \
end start
L/ C1 w0 [: J" [0 ?% G% }3 ~
! V0 e+ N; j M% b9 y
. a1 B& A. K4 j/ f" z |
|