|
发表于 2012-6-1 12:38:44
|
显示全部楼层
我看了一星期小甲鱼关于王爽汇编的视频做出了课程设计,代码如下,哈哈好好学吧
( A. z3 I( ?3 C, z6 Menter macro7 }1 j! Q! p" k
push dx
/ S' i5 Z2 j1 k( w6 S push ax
- |& [/ E. o6 L. B4 c5 V mov dl,0ah/ B1 n& r3 I) [4 r, Y! i
mov ah,2
1 W) \% |, x& L5 I+ j: o int 21h
. X! O$ i, N& @* S1 d" o2 ? mov dl,0dh
0 ?- P3 d& ^, O" k4 Q' W mov ah,2
" j6 \: X3 m" c2 t3 V# ] int 21h
" z5 b) Y+ E) o% g: F' e pop ax
2 d4 J; L @0 p, C. T- m pop dx
! ^3 \( N* E* s3 xendm- m: T. E. s3 ~+ r) p
- R- V$ J: U! t
assume cs:code,ds:data4 J! Z, }# T% v5 k
data segment& H1 F3 z/ ~8 @
table db 300 dup(0)/ g1 f5 C% k# B- u
pro1 db 13,10,'_________________________________________________',13,10" I6 e3 E' S$ T! @) h p+ u1 V3 W
db 'no more than 20 characters English name.',13,107 E& T6 P$ L& Q3 K7 {3 |
db 'For example:',0ah,0dh,'liang xin hui',13,105 M5 d7 \, C: q, _: V0 b. g% N
db 'XXX',13,10,'XXX',13,10,'......',13,10,'...',13,104 U, N1 k0 V" u. @4 q. r& r
db '.................................................',13,10" b4 R4 ]: `# T
db 'Please input:',13,10,'$'
; d' s8 o8 p4 A1 \) ypro2 db '.................................................',13,107 o+ J# Z* L, S, U' ~ [, o5 W
db 'The results are as follows:','$'$ h' R2 m- I4 Y6 k2 x6 Y( ]
% u% \/ {1 f1 k2 Icont db '________________________________________________',13,10* B: E4 [& r0 v) _* C. v! d
db 'Can You Continue(Y/N):','$'
$ }) ^! z2 Y5 a+ e. F2 M4 {9 _
: m& f9 Z$ |' \4 z( M* f2 }cp dd 50 dup(0)
# y L9 h( _" Zdata ends' ?+ X# [' U4 f8 v
4 h# R& M: D: W' S" L7 K
code segment0 r. M& Z3 A; j K9 b( L
start : mov ax,data
4 c0 m6 u G* F, j mov ds,ax
8 e) V+ W2 a1 A* x2 ~+ F call prop1
0 m. ]+ D8 ]" Q7 b5 f1 i mov bx,offset table, [0 z) l1 \! F" X( Q* x) \3 g: u
mov si,0# t) H! m6 d/ \! b* U; r
mov di,0
6 `$ J- |+ ^) d
* h& ^; C& [) q, t' L7 L3 G
$ Q ~- h, ]4 o8 I4 n) M call enterchar1 Y9 b' b# U! B/ A
perp: & J; x$ f# R2 M4 {- M( Q& I6 A
dec si
, v' S ^/ q! B( ^ mov dx,si, E: I0 W J7 f* u
inc si 1 R. X+ s+ I* g
mov cx,si
9 r7 Y) F7 P0 m, w) Y: o* i call arrange
9 j7 K/ R7 ~3 _( ? call prop2
! J: ^# R# k& t7 R* z& w call putchar3 `+ \# M Y2 n) s
liang:
- g0 e5 _; f1 Z, \( W( | call Continue- b% @0 x! p* Y1 \
call judge
- K5 D9 i1 W3 R/ } mov ax,4c00h
2 D, E1 i; ~5 x. D" _1 D int 21h0 v/ ?/ A) @! q3 X( |8 b
) v& C5 Q F3 ~# t/ b V
/ U, _1 R( _" QContinue: enter
" _/ l% z7 B* D4 z$ Y, K+ u mov dx,offset cont
: K1 T" {' a9 Q Y- C! G& `! B8 P mov ah,9h
& f) [ a& M- W" {7 H int 21h8 D* e8 l1 Y8 j6 X
ret
/ M5 `* p0 T- @" S" q; t6 p0 k1 F) l2 T1 r4 l
judge: mov ah,1
* z0 N* s0 g1 }4 M8 s. ~ I int 21h
2 G- V4 Y% @6 L5 { or al,100000b
; W( R- g: A- n/ X7 B: p! y4 @ cmp al,79h4 V' |) h6 Q5 l, L
je clear$ W' g$ i5 o) f: u' r+ G" F( v
cmp al,6eh
k1 i3 ], W/ } je endj
, ~! J6 ] Q9 X6 R( c jmp liang
4 B( A9 A2 w3 O7 z* {& f5 i* qendj: ret
9 ~" T( K2 j$ ]( }& T9 h z, G
$ ?% }, D: ^) f; w* k+ cclear: mov bx,offset table& o }' [- u6 z4 D3 s( ~
mov cx,300
. H2 g6 R, [8 B9 D7 s b, r2 fzero: mov byte ptr [bx],01 X5 H0 i8 `$ ]$ ^5 t) g0 P
inc bx
* ^( H$ t* c0 a. y' w loop zero: B1 T) }. H/ j9 X! E
jmp start) l( N6 y, c' e8 C% Q7 G/ r
( n. h4 q. L K+ v2 }
) [5 X2 V2 W1 e; c
enterchar: mov ah,1" y2 ]7 j$ K; x$ b
int 21h7 z+ s" r3 y% }! u& ~0 D( G
mov byte ptr [bx],al 5 R% _! z4 H9 V/ }, w: I0 Z
cmp al,13
. _- \6 K( R/ Y% Q je endchar
) q% w* ]1 p" z& t2 g mov di,11 x8 D* P1 D! P& l" _
inc bx- r a3 Y; }, H
jmp enterchar7 I# w7 @. M2 F; r; x! t# T' T
# k+ g/ u( J1 M" U/ Tendchar: enter
2 \6 v, t! m' Y mov byte ptr [bx],' '! A- \" _6 i1 N: o7 P7 U
cmp di,0! L, c$ B3 w7 v# H7 I" Z2 ]
je perp& W( J4 g% y6 ]. i1 V
inc si$ ]: u9 d4 n0 J# K ?6 I C/ A# H S @
mov ax,si
9 ]& s- X, [" e: k( c) \# @7 y1 L mov dx,21
& Z7 q8 C! Q' M# R mul dx7 u" z/ N% F6 A% J$ J9 {7 W
mov di,0% J) X" C1 F; P% ~9 ~
mov bx,ax
" h5 ^# T2 J, Z- a jmp enterchar
1 S8 b1 t+ J. |1 I5 i/ c; p" a; {/ K0 | @
arrange: push si& S6 @; J- y R8 L5 ~3 \3 U
push cx
1 {' L% u( P) s8 I8 Q0 u mov cx,dx
/ x G; a# x# F2 o; a mov si,0
! P; [! J4 }) E5 {9 N mov di,21
: M$ p( ~1 _3 n% h: \+ A' v" i* y8 ?1 B! Z+ U* w
s1: push cx
h2 |# P9 Q J: g mov bx,0) F4 R, ]) V/ \7 ?% j2 }) J' V
mov cx,204 j) f; r+ P. n2 q
ss1: mov al,table[si+bx]+ I* j7 y. |( h: L
cmp al, table[di+bx]/ p, D3 ?! I) y- z5 L
ja jiao
! P" |) ?' x! m) a6 ]$ D jb s2
( N' _6 F3 K! ^+ a( m7 d; R! c" f inc bx
% _, r$ D" w. x/ Y2 o; c s7 H7 ] loop ss1
: O- x1 R4 n0 S/ E& f/ s# A, o jmp s28 B; }, n' t0 W. }
$ B E( C6 @( ?: B0 k gjiao: mov bx,0$ J- T8 J0 P. d2 ^
mov cx,20( |( B$ r a3 E+ o) }
jiao1: mov al,table[si+bx]
2 o! N) {/ I7 b xchg al,table[di+bx]
( I6 N- f$ [/ \ mov table[si+bx],al
0 `6 F# [4 H* h: x inc bx$ E( s* W% Q; h0 S0 ` ~3 O3 X
loop jiao1 `* ~' C8 N1 m: k" y n1 P% s1 ?# c
8 r" K, b2 q" V( d& \! T+ }) V* I2 rs2: add si,21
! V) Y' r: O8 [- b, B add di,21
0 A. j7 f4 J( W/ s pop cx
% o" J5 Q$ B3 }% R( d* I" f+ ~ loop s1
; ?# c# C/ {) o3 R; u
" c8 O+ Z. N4 s/ J w) g# V q& Q pop cx
/ }/ S2 q, u3 ?: D7 F pop si
1 e! G" M) U/ X loop arrange$ K3 A* `: _2 o
ret
1 e9 Q" Q. ?) d6 S
7 g" s. ?7 C7 W' J% Pputchar: mov bx,0# Z' ?" X! j* D2 G' _
mov di,1
* S* ]! p& I# b+ P7 U
7 j) \; U, v: B& |9 U0 I, p
3 q% H7 u7 `( T; f+ D; \ mov cx,si
1 r; D+ ]- h. k, ]) w6 w5 Eput1: push cx
8 `# K( s: }, }8 p# \9 y4 T push bx8 W; ]; x: C# ^$ |! V2 w; `: x
4 ?( U# k' }1 Q/ Q* Z) |% q2 d* Q enter
* X# x! r; `* D& P& N
7 E! _( M. X; A8 y! l: ^1 ~& Q( | mov bl,10
% _' {( @! e1 p2 L; l2 R! ?) w. T# E mov ax,di* s1 {% ?* e. C/ ]* G
div bl
" a& L, h5 q* Y7 l6 ~' a, [ mov bh,ah
0 J4 v, B7 G g9 p3 n add bh,30h
* w; `& }5 w/ c! ^5 ~ add al,30h$ B2 ~9 ]5 Z0 K& l$ X
C* \: X4 s' o; P mov dl,al
9 t* y3 M- a4 Q0 V% i8 t) R, F mov ah,2' X7 k0 b7 Y1 d' x5 [3 D7 t, I5 c
int 21h
9 t7 N" w, n6 q, O( z mov dl,bh
. g3 L: b) n( V, L) Q) @! i mov ah,2
: z! |. E# Z- ^' R- q2 y int 21h; \/ s+ w' q4 j' r+ B q6 t
mov dl,3ah
$ ~2 Q2 ], _3 Y% H! J mov ah,2
2 H" J# Y5 D! M! B6 r, U' D9 S int 21h
6 x" r& T* ?0 z pop bx
+ R" P6 k- S6 p& g3 W& ~6 M* c- L mov cx,208 X$ n0 I, c6 j' p" p( Q l
push bx
' Z& {/ Q/ m. X" ]+ q9 Dput2: 2 { \ J' w/ D; z$ M7 \9 w7 A5 A. m$ ?
mov dl,table[bx]
- s) I6 ]* R/ R( T! B) { mov ah,2h
! r6 f" h+ n0 H+ J) b1 c int 21h6 p2 k: X: O# v2 m. ]+ Y! f
/ N1 x: s2 Z) A' Z* t3 H6 b inc bx1 x w3 t4 l0 @) Z
loop put2
2 V4 J9 T4 e, D# t8 X7 H inc di
) ~/ X) N1 H; H1 h5 G# n& q$ C pop bx9 `+ N$ O5 _8 {7 w" d9 O& g
add bx,21
6 U- g* ]2 s8 J1 T/ U2 w9 O' D pop cx
! y. |* E1 C% R6 e& e$ e0 S; f
+ A8 q, |' M) e! U loop put1
: w: |* P6 @0 N6 h: Z6 ` ^% } ret0 l" P2 d. t5 v% K7 E7 I
$ ]8 l5 W. k' I, u0 ~, N5 w& O5 [
prop1:
; z* [ H, w- W: A9 G0 n7 T mov dx,offset pro1
5 U9 S0 `$ r- O: M- l mov ah,9h
3 I2 J5 D) u" C# [; x int 21h% y& A( W2 ^9 N0 d9 x! s
enter $ u3 z7 {* v8 p+ |; t0 \
ret3 J4 r4 N: L# \1 P# l
7 S6 S' y1 H3 Mprop2: enter
3 t; ^! C; G. t+ E mov dx,offset pro26 ]3 a/ g& z g C! v5 e
mov ah,9h
: u# r' g, j2 X, |8 c7 [ int 21h
7 x. V, V6 G3 q$ S2 U, Z ret3 r& T: i4 A( E4 E: D& K" r
8 n% y4 q- v& Q1 a6 P" P
code ends" c0 Y0 Z& `! V" H) q& c# Q5 }
end start( _8 d7 h/ n! f
: s* f/ ]7 G }3 ]" y# \
, E9 C! e( m9 N+ s/ y |
|