|
发表于 2012-6-1 12:38:44
|
显示全部楼层
我看了一星期小甲鱼关于王爽汇编的视频做出了课程设计,代码如下,哈哈好好学吧
8 m0 U. @4 c& I( ~# i" ]( w$ genter macro& z c) b# t0 x" ]; \6 D' ~
push dx
9 p. G+ u# r$ B$ t push ax& O& O# [$ J3 h; }. Y
mov dl,0ah4 `& @% O5 F7 `) s1 S$ M* L
mov ah,2
" B: e0 Y. [2 E# s& _2 U) C! ^9 I int 21h
y& s" N* a6 d& v mov dl,0dh
" K& w4 R) f$ D: F3 N4 u B mov ah,2
" ~% ~. d- S4 ~ int 21h8 B0 N9 N/ e/ S0 ~- i/ v
pop ax- n% }% E) `2 z3 E. ~8 z
pop dx : r4 R" z5 b7 K8 Y
endm
+ f* _" }, d- H- c. D4 j; x; f+ H7 d' A* |$ N
assume cs:code,ds:data/ d$ d6 Z; [! |3 q
data segment
2 J8 {9 m7 F0 \, U Ctable db 300 dup(0)
+ m& h1 e8 J2 U1 }* h+ D$ y9 Q# ypro1 db 13,10,'_________________________________________________',13,10' L3 h, y) T- C. e: d
db 'no more than 20 characters English name.',13,10
) G& u, r3 E8 h4 p& n; H7 b db 'For example:',0ah,0dh,'liang xin hui',13,10
& D: t0 b8 I/ A! O z7 z' L db 'XXX',13,10,'XXX',13,10,'......',13,10,'...',13,10
5 _8 D, E& v* w2 } db '.................................................',13,101 E6 `" S# a p( H3 F$ O1 ]
db 'Please input:',13,10,'$'
" H1 [) U( }1 c" Spro2 db '.................................................',13,105 f2 p, ~( n8 }3 d7 B
db 'The results are as follows:','$'+ t$ [% W! e1 j3 h) v+ t, g' s
2 w3 T' D9 ^' l$ ^; Fcont db '________________________________________________',13,10$ f" V& }8 [0 S+ l6 a, c" Z5 e8 \% L
db 'Can You Continue(Y/N):','$'- ?& X" q, K! R
# H- l6 P I0 h c" J7 @9 L* p
cp dd 50 dup(0)0 P5 |/ R( Y0 n8 [% e ]1 E
data ends; E: ~) U) d; E9 m; ]" q
! w# U0 M1 q n4 ^5 K
code segment
+ ^) E9 ?* c- y7 z/ istart : mov ax,data4 `, i( g5 h% T" ~# R3 }; ]
mov ds,ax( @ L! |/ n: | g$ ~: [$ b
call prop1
J8 R- P7 X2 X. d3 e mov bx,offset table3 Q5 p' k1 l' `& {9 R
mov si,0" V8 W: [2 d$ I; c8 M8 l1 W8 w& F
mov di,04 v9 i* \" B* O% d3 o
& Q8 H$ L ?) g+ p; V
, q' U, T/ o1 {, G6 q9 B
call enterchar
8 |: o' V8 E% U' V! E$ H8 N6 Nperp: 2 w, t; c0 I* _
dec si9 n: `. p) X9 J. G1 F1 \4 _8 k
mov dx,si5 k0 ?1 Q2 E2 }
inc si
. [9 I. i. B7 w- E) R mov cx,si3 F$ s, U! A7 }$ d8 I
call arrange
% p% ?& x- c" u: h call prop2
0 ~8 Y& N% H, B% h call putchar. j; X& u7 n4 Z, ^6 e C
liang:
+ N$ A) e- n | call Continue
$ h, n! f! A1 ?+ w% m call judge
5 R1 c: s0 e8 @4 `/ w mov ax,4c00h3 f( ^( T o4 E. ?' S9 ^- F
int 21h
/ B% Y& _6 D- |5 o% i4 E) J9 k, J+ x1 ~* C* I4 A
( O7 n7 v. ^3 _! B' e4 ]# _) t4 A
Continue: enter* K3 x( d+ h" v* |' e9 T5 M
mov dx,offset cont
' @8 N: S/ H7 D+ G mov ah,9h
{% B$ F* N7 X- }8 ?+ c int 21h
! ^; ^* `5 I, d! A; x7 A( C- n ret 0 u1 J ~' p3 ]9 p2 R8 R9 Y
+ _; Z' t) W$ p3 [3 Q/ Y% B* i4 xjudge: mov ah,1! w' ~ o% v. v1 K: U: V5 i
int 21h
2 ]0 S) T' d* q& G. Q' S( c or al,100000b
7 ?, n n. ^0 I. w/ ` cmp al,79h7 @: K3 w2 O; N% A
je clear
" D' J1 X' p# ? cmp al,6eh
. r8 S, X& q, X; ~: ]: f je endj7 ~% Y$ s, Y5 w9 O! ^1 M
jmp liang
' N1 i' n: R9 v* d: Qendj: ret & H, B K4 g# j; w0 g; a, p
, _+ i$ n! s* A3 s, n/ Jclear: mov bx,offset table3 ]) u( y/ v2 T: L( j) a0 n
mov cx,300% \6 Y. R7 [( v: v3 x1 Y
zero: mov byte ptr [bx],0
+ X: f9 X6 l5 t/ ?: I inc bx5 H) x0 C( m) p {
loop zero
* H( [* z7 l7 @! ^$ S+ l9 e0 j jmp start
' H- v. H8 Y- ~! U& ^1 }' r+ h4 i2 l
/ F8 j$ U$ k0 s+ I1 f
enterchar: mov ah,1! t! C0 ~6 W6 g
int 21h2 j! g- u. c; t: f
mov byte ptr [bx],al
' Y1 {* m- z) `4 U cmp al,138 i2 i' o/ m+ N0 Q. K/ t3 H( V
je endchar
$ ]+ `% x, b% v! d" X1 m mov di,1) a0 a A! P$ O" k
inc bx
/ k4 ]& `& f, B2 ~! | jmp enterchar
2 z1 I8 M% D4 x! Y/ w& p5 S% \# B; @
endchar: enter # q! L5 r# D$ G2 g2 j
mov byte ptr [bx],' '. G' e' [5 [9 L8 ~/ @, F" c5 Y
cmp di,0' K7 O' Z, Z+ j2 X% k8 u
je perp
; y' }4 p* z& X7 Y: M8 b1 l inc si
' y# m# e H- U8 @ mov ax,si2 N* O' L7 v. H0 Q
mov dx,21 h0 w+ v2 z" I4 a! g( s' H
mul dx
* U3 M* X$ p0 X+ M mov di,0. z, u$ E4 H) _0 ?
mov bx,ax : c* p/ W8 [ C/ a2 f
jmp enterchar- Y6 g8 z! Q' r* R, s+ Y6 x0 _- h$ M
& V- p3 `3 z q a6 @9 f
arrange: push si
# _5 S8 v: q. _, F push cx / [& R9 W* w4 z( H
mov cx,dx 5 M! Z- V" \& ]& j3 q
mov si,07 S* u* w2 m; q0 `& }
mov di,213 C2 I- Z0 G6 X5 X ]6 x9 F+ P
0 `8 U- v& N5 C Fs1: push cx/ L: F8 E, O$ \$ F
mov bx,03 {% x$ q# Y$ e
mov cx,20' k9 z" V2 L( r1 s6 P
ss1: mov al,table[si+bx]3 b+ G! E; u) l# N) V. g o. L/ Z
cmp al, table[di+bx]: D3 ~6 H3 _+ X' y7 M
ja jiao2 S4 o( J9 E* @) R' ~4 B
jb s2$ T2 N& W% s& M9 Y! P' X+ u
inc bx. f+ q3 b' o3 `; \' N
loop ss1
' t) M$ S% M9 `# _9 b& j jmp s2
3 ]' y; Y% t4 |' e6 [5 y
1 N4 o6 j [) p) p* N5 w7 Wjiao: mov bx,0
/ a+ C: T% L1 X' _2 x7 ` mov cx,20/ j( n* C ]/ O! c7 `0 ]
jiao1: mov al,table[si+bx]
: @, E: E1 Q" i& J) d, g( x xchg al,table[di+bx]3 l0 x. m4 d5 k& D. U+ L
mov table[si+bx],al
6 k0 Y8 i2 R9 V5 a inc bx8 \/ A$ ^& a+ h/ Z) F
loop jiao14 X. N V$ Y5 V! x" M6 R8 O
; D/ u$ b J/ H3 t
s2: add si,210 w& L8 ]" t! {2 J
add di,21/ b- A: I2 l6 s% f8 I$ U4 i* q
pop cx
9 g/ t& G8 c- T- j2 `) X loop s1
4 H* C3 z/ z& T# f$ @" ^9 n5 c, `
6 C) } }& y* R5 e pop cx
7 \: ?5 ?; p+ j. [* t pop si
o9 v2 ]# U: H/ R/ `& u0 U1 _ loop arrange2 W$ C5 X; V, _! M! E. v! b
ret r1 D& {9 K& X! W+ A0 a
7 q3 x' _% Q5 o3 u5 r8 @' q. j
putchar: mov bx,09 f# A4 v# S! @: f" l
mov di,1( D& w2 l: b) b% r; @* c$ V" j
7 q8 j+ t2 v5 K" m
0 G' ?5 `; \+ w. z7 z
mov cx,si9 R* D( Z. S( W Z5 d! _" ~4 i' a
put1: push cx
; |" ~8 t9 B+ z2 }1 C/ ?( [" h, E push bx
; P, z: d/ Y0 S* T$ d ]8 }. h; J1 A1 i
enter( r0 m( L# O, H% J8 v0 A
. ?! Q& [, O8 P
mov bl,10; ]" S# @; I7 J* E7 e: b, B8 v
mov ax,di
4 C/ a! u6 X; T# q5 }, g% m. r0 Q2 m div bl1 O" a( @( y1 b' E% _* Y* p8 e
mov bh,ah5 s. H: j) r& b" y& ?; p
add bh,30h. u" O6 X* y$ Y; j3 h
add al,30h
0 l1 @: p D8 ] g' | - H2 u3 [7 n: ?0 D2 C' ?
mov dl,al
* C% [$ Y ], l, q: |. Q9 I mov ah,2
+ O3 w0 k- i$ z6 v* ~0 r" j; u int 21h: v5 J3 b/ l! z/ t6 M7 Z- p1 [. y7 Q
mov dl,bh
3 h4 W. t/ f, d, r) l mov ah,2
7 \& i+ @4 H) Q2 Y int 21h) K( k" x( D) v; F" G$ w: A
mov dl,3ah# O: S, N: g1 A$ w% H# f
mov ah,23 B" {' N f+ m* M5 ]: f
int 21h; o- g6 U0 _' H l M) V$ u
pop bx
0 l' l# \6 \7 M" A4 g' [3 k7 z; { mov cx,20
7 _ c/ y" q- ? push bx0 o0 e( t/ f/ z
put2: ( Z. d8 m5 n7 E
mov dl,table[bx]
. `5 \# t- Q- I* ?. Z! P/ ^9 r mov ah,2h i' z: L/ M# p8 B: H1 C
int 21h0 C* Y: x& ~# t* Z
1 m' S( l) @' c/ j inc bx6 J& v5 Y+ M7 s9 \: h& t5 `
loop put2
7 n0 }- [; |2 d% U( y* y8 R inc di & T: V q$ b# w5 G0 T; V
pop bx
# f( Z! Q/ E* v# i7 v! n add bx,21( c$ V/ J+ h7 `1 o4 j
pop cx
( f t$ f! a, X1 B' c, P( I
! Q* B* V$ X! t3 f' x! |' n9 t loop put1; y- s+ u% |) S( r, p0 Y* j
ret% Y/ K: D0 {6 T$ z
0 K5 c5 p$ u" _2 U* k3 ^prop1:
, a+ `6 s- k3 R- m* O mov dx,offset pro1$ s" o. `5 t' Z5 r- m6 t6 Y1 ?8 f
mov ah,9h7 H. z) Q1 @ E5 i# b. ^
int 21h
6 ~; Y% [6 B/ y$ s8 n enter 2 |# F5 F1 s' ~
ret* K6 j2 M7 i6 u. F, e0 E
$ g' z* R# f( J8 Q H( rprop2: enter" Z3 d* Z7 m G' ]6 u0 q
mov dx,offset pro2
6 k2 J, T; {5 d, ~! Q mov ah,9h
J% @( u- s; }: A& R int 21h
9 E8 A. e* r% ?8 y5 [$ G ret3 i1 u6 {9 V9 s: J
; d& ]7 o/ P3 ncode ends
% D& ?9 r6 f% w# p1 f6 w% yend start
9 T1 @8 L/ r8 R' x7 p5 T) s2 ]; ?, T; H& ?8 ^) m) d" s
: L& P; q: `1 W6 ]. I+ U |
|