|
发表于 2012-6-1 12:38:44
|
显示全部楼层
我看了一星期小甲鱼关于王爽汇编的视频做出了课程设计,代码如下,哈哈好好学吧
/ o5 U) ~; X% K$ p& J: h5 P6 z7 venter macro& N0 C- ^9 A% |/ L! [) ^, O: A
push dx
/ N) b/ d0 T! q! O' Q push ax! W9 f. p; @4 O* B9 m
mov dl,0ah( e0 w; W* H0 t2 k) m
mov ah,2
# N/ Y6 L) O1 Q( u& S int 21h/ h, @% s# k) v! L. @" V- A
mov dl,0dh
& k' B# g0 R* x7 y) @6 J2 q mov ah,2
+ g5 i a. B8 w/ Q6 j( S int 21h) v" O6 x' H& ]8 z) V7 K( Y) w
pop ax. E5 J9 v' \& L1 ]
pop dx ! O0 C& t! J( A! ?0 q$ L u
endm( ]! U; c. `% z3 h; A
8 _" @* _0 F0 |% U; Q
assume cs:code,ds:data
; ~) R2 o. U, }- f# G mdata segment$ h0 a( }9 C8 U
table db 300 dup(0)
E2 D6 T$ C( J$ g' i& xpro1 db 13,10,'_________________________________________________',13,10
9 ^4 \# k; T% V, y db 'no more than 20 characters English name.',13,10# c0 v# F' s. q% e! o, J( _
db 'For example:',0ah,0dh,'liang xin hui',13,10& x' z3 L; M1 k: h" Z- d9 w3 _
db 'XXX',13,10,'XXX',13,10,'......',13,10,'...',13,10. b3 R! l* J. j" V1 c7 @3 N. q1 {
db '.................................................',13,10
' C1 g! g4 ]6 j6 v0 L; O: M db 'Please input:',13,10,'$'
3 K3 N7 O i) @) S7 @9 S I' _pro2 db '.................................................',13,10
9 j' o5 K) O" l db 'The results are as follows:','$'4 T6 M# { H) ?5 t
' ?+ Z( _3 Q! G' R Ycont db '________________________________________________',13,10- Z) X' U7 \2 k
db 'Can You Continue(Y/N):','$'
- M z0 a- _1 e G( Q8 |! L9 f. k# L* d, B. @- i! r- Q
cp dd 50 dup(0)6 ^" }9 M/ p; e
data ends
$ I) w8 r% p" S' A8 z6 H
h3 }# c* @( @2 f' z1 mcode segment1 [) m9 H9 Q* ]
start : mov ax,data1 F; ~. l7 I2 g
mov ds,ax
5 V; v, {- w; \0 }* l& w$ E( u call prop1- q; J$ } M9 u, J% X% N
mov bx,offset table/ y+ e2 H; L" I
mov si,08 t& V& a' i- j: k2 `
mov di,0% n8 G6 y' F( S7 L
5 m9 E ~3 M$ g$ Y. O
5 l! [+ s6 T6 L; L' N call enterchar8 K/ L9 S! {- d' @9 X
perp: ; f$ U) i2 X4 y
dec si
. R V/ G" D" ]: n! z, O+ D9 p mov dx,si$ M! o# `* ?% K/ T' n
inc si " \ o! U7 N2 f5 K3 Q. G& Y2 V0 E
mov cx,si' A# m: e. N4 w8 r2 H' N0 h
call arrange
- t7 S7 s% U5 U1 ? call prop2) m+ J! I3 Y: x3 L6 l% x/ D
call putchar
) ]9 w' l* g8 p* G* U: B; Q# G# _liang:6 X# F9 O8 g; _4 C9 ^, q. [
call Continue
# s/ Y/ W* n' g6 U* F; A call judge0 M/ S" k7 y2 x% ^( ?
mov ax,4c00h, J7 ?& o) D2 i0 A }
int 21h
. n1 L$ ^% w$ d5 r- E+ Z' G5 j8 {
: m0 C! L3 c1 o$ O- J+ T" v* m: U$ q$ p
Continue: enter
( k) T( x5 k7 X mov dx,offset cont
- _7 S/ v6 Z; k# O, x! J- V0 ` mov ah,9h
2 R1 G' U3 G4 t5 i& S! M int 21h
) p' L3 i# t o: m( W ret ( y w! `4 J4 Q* f3 `0 ]' o
+ O9 V+ c. P! {; N1 |1 z5 n, y# J; @
judge: mov ah,1
% B+ H! J9 Q1 b/ `2 a6 ?7 Q4 K" L int 21h
& S; v% B3 p7 U, I1 V# e or al,100000b' h+ [5 W% f, {$ w* q, W& w2 ~
cmp al,79h% u" b0 d; B3 P
je clear
7 ?4 H, n" Q- B. ]# N i7 ]6 | cmp al,6eh6 I' M/ z% d2 P8 R* p* |
je endj
3 U% r0 R2 ]2 a) x- d jmp liang
6 Q& s8 E0 y& F. N3 } bendj: ret
' P) U4 H9 H% W8 B* o8 S ! J+ S1 q# K' }* d! M( }3 |
clear: mov bx,offset table" |( O* C) E8 s1 N: z
mov cx,300% x4 K6 a0 e' w/ L d
zero: mov byte ptr [bx],0' Y; M1 A% R! U/ [7 y5 J
inc bx: e6 V' O4 @ v9 |! @
loop zero
1 B4 J# n7 }% k9 U) I$ e. h jmp start
0 M a3 m; A% a6 E6 S. Q* }5 p9 D' ]2 A& \# q! }* v7 B4 G" V( U& I
( J) E& b& I, L. ?
enterchar: mov ah,1
( k% n5 r' M! j/ v9 C, W int 21h
, ?( g/ A, P C; J* V mov byte ptr [bx],al
4 R1 `; o; n4 j- Z8 U: l) _ cmp al,13
3 ~0 o" [4 |4 k$ m! l# W* a0 l je endchar
+ z! v% ^0 _ ~& C mov di,1
# B* x* ^7 `- c( L0 I inc bx& H6 L) w- Y# M" B
jmp enterchar
$ x) T0 u( C9 i0 B; E: r9 O7 J0 v) y4 U8 U8 E% D: A# D: v
endchar: enter
7 Y1 M/ D- r8 O% { mov byte ptr [bx],' '
( g4 _& ]' f3 b3 U cmp di,0
( k% @, M; F4 V* z$ T/ | je perp4 m' Y$ {' C9 m, i1 ]6 I; Q
inc si
. d1 n; b A8 J2 x mov ax,si
" A5 ~( b1 t; L7 H mov dx,21- `: H7 Y" a7 D0 j7 f4 B7 d& M! Z
mul dx
8 G9 c1 `5 j/ F mov di,0; B. T8 c+ O2 E0 S7 a5 x
mov bx,ax
+ I* C+ L) K! x jmp enterchar" M" X& e$ H; Q) h
7 r/ X( h8 f, j& k! b7 O u3 w
arrange: push si5 D8 ? d$ W# l& {9 u+ }
push cx - m" v9 l5 Z: X/ x3 I
mov cx,dx 6 P1 g$ ~! E3 \0 M: Z+ R, ~2 _; X4 ^
mov si,0
! a X2 a* B+ g$ T mov di,21
3 w) p% X/ r2 W: S
$ p; S' x8 ^% Z, _s1: push cx
5 |$ `% Y' Y1 V- H5 }. l mov bx,0
) ?3 D t: i& }; q9 q& l: s8 C mov cx,20, r, r; ]9 t8 K1 S
ss1: mov al,table[si+bx]
0 Y; U: V' _* q9 A cmp al, table[di+bx]% H5 |2 I/ M! V5 l6 P
ja jiao
. ~% {3 c5 ]; _7 O: `8 w: ]& @& U8 I jb s2) [" {" p1 `( h$ j1 |
inc bx5 {7 ~0 ^9 w$ a9 N9 `( t8 a( Z, j
loop ss1
' K, S1 W+ E1 L' u: X jmp s2& I# | l2 l4 D; K
7 x" h' w( C" C' V3 _+ V8 Ujiao: mov bx,0& ^- j) V+ K x! W
mov cx,207 X" i# l7 Z$ t1 l. b; V
jiao1: mov al,table[si+bx]1 J8 V6 Q# J. o( B/ J/ {0 A4 `
xchg al,table[di+bx]
6 B. g6 O3 V3 H mov table[si+bx],al
& F/ _8 e; F- h inc bx$ o" e# J" H$ i# X
loop jiao1
5 |0 Z9 V: a% d1 Y( a9 L- B) [. x# C' C7 }+ g5 p/ }8 z
s2: add si,21
; n+ p! t$ g: p n9 g' t+ u add di,21
) U, M+ @5 M; w. n pop cx
4 \1 P1 e$ z/ y# D loop s1
* u+ q5 [. z5 @7 S$ I- V% |( L% k7 X! ~9 _9 ~) ?4 r! t
pop cx |8 i* l- \. X; ?
pop si
/ A, D, Y9 D& X/ f, U8 Q7 i9 g loop arrange' _) r, ?0 v. S3 j2 q+ q" w
ret
, e' c# Z6 a$ K4 `- s% ^- ?- H/ K9 l5 L
putchar: mov bx,0
4 ~, i5 b+ s- g. }/ ?. \: v! T mov di,1
' m `- T, g- I4 i6 u
: A7 U* g5 S; e* y2 @
; q- m, m/ j5 i H mov cx,si
0 X3 l# W; }0 [% t& V# Hput1: push cx
8 f+ L- G' A: ^/ j A4 J% l push bx- V. g& @/ a' [
+ Y& F8 L- F6 e; e) t6 X3 i enter$ H3 B4 T. e. s' Z
) d7 j6 f1 {3 {: X% q% ^) A
mov bl,10
4 @. n0 h( O2 q9 w4 Q4 p mov ax,di& N' J- ^1 I' [; o0 {0 M1 ^8 r
div bl E( [# m3 t! c) m. ?8 D
mov bh,ah2 O5 N" P Y. E) p: y
add bh,30h5 N; ^- j8 [+ Q
add al,30h% I3 F; a$ L5 x: q2 ~& T
4 W1 h" o& m1 g: P mov dl,al% Z- \$ X3 a3 v4 d9 m$ W
mov ah,2( _$ ~! i; D7 v0 V
int 21h2 S, V( g; i7 A
mov dl,bh8 \( T V- D* H! o6 f/ v/ o" P
mov ah,2
8 _3 Y, `4 C/ g# T+ K int 21h* q3 O0 |! ?. v/ i( t2 Y2 {( n$ V" c
mov dl,3ah
; y3 n. R! _3 M8 }+ H mov ah,2) q) ~8 F9 v, |( e& r) ^9 v
int 21h0 O2 N, G% `! ~( a
pop bx
7 Q7 U- n( B2 _9 x" N% |1 E mov cx,20
& J+ m* F t0 C5 n4 _# e8 R* ^ push bx
% n3 E, e: \3 I" T& nput2: " a, m9 X; n9 d( r" V- \
mov dl,table[bx]
( h H0 I/ C3 M mov ah,2h
u- d1 K# {, ]! o. O D! x int 21h
3 x" W. O* B- t# X 9 O6 b" r# u/ Q; ?0 A
inc bx5 h( I B- W9 S: {* z
loop put2- }4 D# h2 Y- v" p
inc di 1 j; i6 \2 V- x* E
pop bx
! B; T0 l9 c& j4 z7 L add bx,21
! M9 N" s$ Y) [/ v; ] pop cx
' w% `2 w d R$ X8 {7 p " \& C' p( c8 N/ K S$ P9 m
loop put13 d' H1 z1 E+ @9 B
ret
* K' O* G0 u- Y* s$ M& E2 a. @9 [, |
5 @% ]3 F: \! S& J2 \2 h+ @1 R/ mprop1: 7 ?" k% i8 P: D; o
mov dx,offset pro1. }" I/ u5 H o3 E
mov ah,9h
1 B ^3 ?1 H, g7 E int 21h7 p& R6 s0 a& e8 [5 T2 C8 a, [
enter - T- X6 j! c5 I7 H2 O/ k8 A
ret. Y( P2 I7 x* U7 y- `
, G+ f# ~* y7 f7 q+ Xprop2: enter
5 w D; x' L3 _ I3 g mov dx,offset pro2' q3 T5 o9 s* R% B( C2 c
mov ah,9h2 `, Y* j: t+ q, C* r: u, n
int 21h8 S0 B5 n4 _2 @0 N( f0 a( l
ret
8 G: y* M* L) [1 ~: ~2 e8 W0 S4 |1 K" `* G
code ends: k* p! Q! B7 w' M+ f0 J& x
end start
$ C, j. D; ?* ]! Y
& r5 l. D9 M6 B( Y' V: b6 w6 w8 R0 v# {% I& I
|
|