co_progs use full programs
TRANSCRIPT
-
8/13/2019 CO_progs use full programs
1/35
PROGRAME CODE :
TITLE Displaying a simple text.MODEL SMALL
.STACK 100h
.DATA
MSG DB 1 !10! " A#$isan%a&a C'llege '( Enginee&ing ) Te*hn'l'gy+ASCET, -"
.CODE
MO A/! DATA Get a$$&ess '( $ata segment
MO DS!A/ St'&e a$$&ess in DS &egiste&
MO A2! 032 $isplays a st&ing
LEA D/! MSG msg is l'a$e$ t' D/ &egiste&
I4T 512 Call t' DOS
MO A2!6C2 Te&minates the
I4T 512 p&'*ess (&'m DOS.
E4D
-
8/13/2019 CO_progs use full programs
2/35
PROGRAME CODE :
TITLE 7in$ing that 8hethe& the gi9en n'. is e9en '& '$$
;I4T MAC;O MSG MO A2! 032 $isplays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 exit t' DOS
E4DM.MODEL SMALL.STACK E 4E/T MO BL!AL M'9e AL t' BL MO AL!4 M'9e 4 t' AL M?L CL M#ltiply CL 8ith AL ADD AL!BL M'9e BL t' AL
MO 4!AL M'9e AL t' 4 MO A2! 012I4T 512
>M ;EAD >#mp t' ;EAD la=le
4E/T: MO AL!4
MO BL!5 BL @ 5 DI BL
CM A2!00 Is &emain$e& in A2 is e #al t' 0
>E LAST I( s'! g't' next ;I4T ST >M CLOSE G't' last
LAST: ;I4T ST5 Call ;I4T ma*&' ('& ST5
CLOSE: MO A2!6C2 ;e #est t' en$ p&'g&am exe*#ti'n I4T 512 Exit t' DOSE4D
-
8/13/2019 CO_progs use full programs
3/35
PROGRAME CODE :
TITLE A$$iti'n '( t8' n#m=e&s
;I4T MAC;O MSG MO A2! 032 $isplays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste&
I4T 512 exit t' DOSE4DM.MODEL SMALL.STACK M E/IT LAST: ;I4T ST6 E/IT: MO A2!6C2 ;e #est t' en$ p&'*ess I4T 512 Call ('& DOS MAI4 E4D ;EAD ;OC 4EA; /O; B/!B/ Clea& B/ &egiste& MO A2!012 ;ea$ a *ha&a*te&
-
8/13/2019 CO_progs use full programs
4/35
-
8/13/2019 CO_progs use full programs
5/35
PROGRAME CODE :
TITLE S#=st&a*ti'n '( t8' n#m=e&s;I4T MAC;O MSG
MO A2! 032 $isplays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 exit t' DOS
E4DM.MODEL SMALL.STACK L 4O?T S?B A/!B/ S#=st&a*te B/ (&'m A/ CALL 4?M Call 4?M p&'*e$#&e >M J?IT 4O?T: ;I4T ST J?IT:
MO A2!6C2 ;e #est t' en$ p&'*ess I4T 512 Call ('& DOS MAI4 E4D ;EAD ;OC 4EA; /O; B/!B/ Clea& B/ &egiste& MO A2!012 ;ea$ a *ha&a*te& I4T 512 Call ('& DOS
-
8/13/2019 CO_progs use full programs
6/35
-
8/13/2019 CO_progs use full programs
7/35
PROGRAME CODE :
TITLE M#ltipli*ati'n '( t8' n#m=e&s;I4T MAC;O MSG
MO A2! 032 $isplays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 exit t' DOSE4DM
.MODEL SMALL
.STACK E 4E/T i( e #al H#mp t' 4E/T
-
8/13/2019 CO_progs use full programs
8/35
-
8/13/2019 CO_progs use full programs
9/35
-
8/13/2019 CO_progs use full programs
10/35
/O; B/!B/ Clea& B/ &egiste& MO A2!012 ;ea$ a *ha&a*te& I4T 512 Call ('& DOS LOO 1: CM AL!1 C'mpa&e AL an$ 1
>E 4E/T i( e #al H#mp t' 4E/T CM AL! 0 C'mpa&e AL an$ 0
>4GE CLOSE i( e #al H#mp t' CLOSE CM AL! 3 C'mpa&e AL an$ 3
>4LE CLOSE i( e #al H#mp t' CLOSE A4D A/!00072 Get the n#m=e& in t' A/ ?S2 A/ M'9e A/ t' sta*% MO A/!10
M?L B/ M#ltiply A/ 8ith B/ O B/ Sta*% B/
ADD B/!A/ MO A2!012 I4T 512 >M LOO 1 G' t' L''p1 4E/T: ;ET Call &et#&n t' MAI4 p&'*e$#&e CLOSE: ;I4T ST MO A2!6C2
I4T 512 ;EAD E4D
4?M ;OC 4EA; MO C/!00002 Clea& C/ &egiste& MO B/!10 GO?T: MO D/!00002 Clea& D/ &egiste& DI B/ Di9i$e A/ =y B/ ?S2 D/ M'9e D/ t' sta*% I4C C/ In*&ease C/ O; A/!A/ D' O; t' =e('&e ) A(te& A/ >4E GO?T
O?T: MO A2!052 ;e #est t' p&int a *ha&a*te& O D/ sta*% t' D/ O; DL! 02 get the *ha&a*te& I4T 512 LOO O?T D' the l''p #p t' C/ 0 ;ET Call &et#&n t' MAI4 p&'*e$#&e 4?M E4DE4D
-
8/13/2019 CO_progs use full programs
11/35
PROGRAME CODE :TITLE 7in$ing the 7a*t'&ial '( the gi9en n#m=e&
;I4T MAC;O MSG MO A2! 032 $isplays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 exit t' DOS
E4DM.MODEL SMALL.STACK 4GE LAST i( e #al H#mp t' LAST
CM AL! 3 C'mpa&e AL an$ 3
>4LE LAST i( e #al H#mp t'LASTS?B AL! 02 S#st&a*t 6 (&'m al
MO CL!AL M'9e AL t' CL ;I4T ST5 CM CL!0 C'mpa&e CL 8ith 0 >E O4E I( e #al g' t' O4E MO A/!00012 A/ 1 7ACT: M?L C/ M#ltiply A/ 8ith C/ LOO 7ACT D' the l''p #p t' C/ 0 CALL 4?M Call 4?M p&'*e$#&e >M E/IT O4E: ;I4T ST6 >M E/IT LAST: ;I4T ST E/IT: MO A2!6C2 ;e #est t' en$ p&'*ess
-
8/13/2019 CO_progs use full programs
12/35
I4T 512 Call ('& DOS MAI4 E4D 4?M ;OC 4EA; MO C/!00002 Clea& C/ &egiste& MO B/!10 GO?T: MO D/!00002 Clea& D/ &egiste&
DI B/ Di9i$e A/ =y B/ ?S2 D/ M'9e D/ t' sta*% I4C C/ In*&ease C/ O; A/!A/ D' O; t' =e('&e ) A(te& A/ >4E GO?T O?T: MO A2!052 ;e #est t' p&int a *ha&a*te& O D/ sta*% t' D/ O; DL! 02 get the *ha&a*te& I4T 512 LOO O?T D' the l''p #p t' C/ 0 ;ET Call &et#&n t' MAI4 p&'*e$#&e 4?M E4DE4D
-
8/13/2019 CO_progs use full programs
13/35
PROGRAME CODE :TITLE &int the 7i='na**i se&ies #p t' the gi9en n#m=e&
;I4T MAC;O MSG MO A2! 032 $isplays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 exit t' DOSE4DM
.MODEL SMALL
.STACK LE E/IT I( less than '& e #al g' t' E/IT S?B 4?M!5 S#=st&a*t 5 (&'m 4?M ;I4T ST SE;IS: ;I4T S C Call ;I4T ('& spa*e /O; A/!A/ Clea& A/ /O; B/!B/ Clea& B/ MO A/! AL A/ AL ADD A/!4O A$$ 4O t' A/
MO B/! AL B/ AL MO 4O!B/ 4O B/ MO AL!A/ AL A/ CALL 4?M MO B/! AL B/ AL CM B/!4?M C'mpa&e B/ 8ith 4?M >4GE SE;IS I( n' g&eate& '& e #al g't' SE;IS
E/IT: MO A2!6C2 ;e #est t' en$ p&'*ess I4T 512 Call ('& DOS
-
8/13/2019 CO_progs use full programs
14/35
MAI4 E4D
;EAD ;OC 4EA; /O; B/!B/ Clea& B/ &egiste& MO A2!012 ;ea$ a *ha&a*te& I4T 512 Call ('& DOS GET:
CM AL!1 C'mpa&e AL an$ 1>E 4E/T i( e #al H#mp t' 4E/T
CM AL! 0 C'mpa&e AL an$ 0>4GE CLOSE i( e #al H#mp t' CLOSE
CM AL! 3 C'mpa&e AL an$ 3>4LE CLOSE i( e #al H#mp t' CLOSE
A4D A/!00072 Get the n#m=e& in t' A/ ?S2 A/ M'9e A/ t' sta*% MO A/!10
M?L B/ M#ltiply A/ 8ith B/ O B/ Sta*% B/
ADD B/!A/ MO A2!012 I4T 512 >M GET G' t' GET 4E/T: ;ET Call &et#&n t' MAI4 p&'*e$#&e CLOSE: MO A2!6C2
I4T 512 ;EAD E4D
4?M ;OC 4EA; MO C/!00002 Clea& C/ &egiste& MO B/!10 O ?T: MO D/!00002 Clea& D/ &egiste& DI B/ Di9i$e A/ =y B/ ?S2 D/ M'9e D/ t' sta*% I4C C/ In*&ease C/ O; A/!A/ D' O; t' =e('&e ) A(te& A/ >4E O ?T S2OF: MO A2!052 ;e #est t' p&int a *ha&a*te& O D/ sta*% t' D/ O; DL! 02 get the *ha&a*te& I4T 512 LOO S2OF D' the l''p #p t' C/ 0 ;ET Call &et#&n t' MAI4 p&'*e$#&e 4?M E4DE4D
-
8/13/2019 CO_progs use full programs
15/35
PROGRAME CODE :TITLE &int the s#m '( n nat#&al n#m=e&sDIS MAC;O MSG Ma*&' ('& message p&inting MO A2! 032 $isplays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 exit t' DOSE4DM
.MODEL SMALL
.STACK 4GE J?IT
-
8/13/2019 CO_progs use full programs
16/35
CM AL! 3 C'mpa&e that is @ 3 >4LE J?IT
A4D A/!00072 T' get the n#m=e& ?S2 A/ M'9e it t' sta*% MO A/!10 M?L B/ M#ltiply A/ 8ith B/
O B/ Sta*% B/ ADD B/!A/ MO A2!012 &ea$s a single *ha&a*te& I4T 512 *all DOS >M ;EAD 4E/T: ;ET Call &et#&n t' MAI4 p&'*e$#&e J?IT: MO A2!6C2 I4T 512 ;4?M E4D
4?M ;OC 4EA; MO C/!00002 Clea& C/ &egiste& MO B/!10 GET4: MO D/!00002 Clea& D/ &egiste& DI B/ Di9i$e A/ =y B/ ?S2 D/ M'9e D/ t' sta*% I4C C/ In*&ease C/
O; A/!A/ D' O; t' =e('&e ) A(te& A/ >4E GET4 ?T4: MO A2!052 ;e #est t' p&int a *ha&a*te& O D/ sta*% t' D/ O; DL! 02 get the *ha&a*te& I4T 512 LOO ?T4 D' the l''p #p t' C/ 0 ;ET Call &et#&n t' MAI4 p&'*e$#&e 4?M E4DE4D
-
8/13/2019 CO_progs use full programs
17/35
PROGRAME CODE :
TITLE &inting =iggest '( gi9en t8' n#m=e&sS2OF MAC;O MSG Ma*&' ('& message p&inting MO A2! 032 Displays a st&ing
LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 Exit t' DOSE4DM
.MODEL SMALL
.STACK G 7I;ST I( g&eate& g' t' 7I;ST S2OF MSG6 Call S2OF ma*&' ('& MSG6 >M E/IT 7I;ST: S2OF MSG Call S2OF ma*&' ('& MSG
E/IT: MO A2!6C2 ;e #est an en$ t' exe*#ti'n I4T 512 Call $'s BIGGEST E4D
;EAD 4?M ;OC 4EA; /O; B/!B/ MO A2!012 I4T 512 GETF:
-
8/13/2019 CO_progs use full programs
18/35
CM AL!1 C'mpa&e that is en$ '( the n#m >E 4E/T
CM AL! 0 C'mpa&e that is 0 >4GE CLOSE
CM AL! 3 C'mpa&e that is @ 3 >4LE CLOSE
A4D A/!00072 T' get the n#m=e&
?S2 A/ M'9e it t' sta*% MO A/!10 M?L B/ M#ltiply A/ 8ith B/ O B/ Sta*% B/ ADD B/!A/ MO A2!012 &ea$s a single *ha&a*te& I4T 512 *all DOS >M GETF 4E/T: ;ET Call &et#&n t' BIGGEST p&'*e$#&e CLOSE: MO A2!6C2 I4T 512 ;EAD 4?M E4DE4D
-
8/13/2019 CO_progs use full programs
19/35
PROGRAME CODE :
TITLE &inting the length'( a st&ing
S2OF MAC;O MSG Ma*&' ('& message p&inting MO A2! 032 Displays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 Exit t' DOSE4DM.MODEL SMALL.STACK 4E 4E/T I( s'! g't' 4E/T
S2OF MSG5 S?B C/!1 S#=st&a*t 1 (&'m C/ MO A/!C/ C/ A/ CALL ;I4T 4?M
MO A2!6C2 ;e #est an en$ t' exe*#ti'n I4T 512 Call $'s MAI4 E4D
;I4T 4?M ;OC 4EA; MO C/!00002 Clea& C/ &egiste& MO B/!10 O ?T:
-
8/13/2019 CO_progs use full programs
20/35
MO D/!00002 Clea& D/ &egiste& DI B/ Di9i$e A/ =y B/ ?S2 D/ M'9e D/ t' sta*% I4C C/ In*&ease C/
O; A/!A/ D' O; t' =e('&e ) A(te& A/ >4E O ?T G ?T: MO A2!052 ;e #est t' p&int a *ha&a*te& O D/ sta*% t' D/ O; DL! 02 get the *ha&a*te& I4T 512 LOO G ?T D' the l''p #p t' C/ 0 ;ET Call &et#&n t' MAI4 p&'*e$#&e ;I4T 4?M E4DE4D
-
8/13/2019 CO_progs use full programs
21/35
PROGRAME CODE :
TITLE &inting a st&ing in gi9en n'.'( times
DIS MAC;O MSG Ma*&' ('& message p&inting MO A2! 032 Displays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 Exit t' DOSE4DM
.MODEL SMALL
.STACK
-
8/13/2019 CO_progs use full programs
22/35
MO A2!012 ;ea$ a *ha&a*te& I4T 512 Call ('& DOS GETF: CM AL!1 C'mpa&e AL an$ 1
>E 4E/T i( e #al H#mp t' 4E/T
CM AL! 0 C'mpa&e AL an$ 0
>4GE CLOSE i( e #al H#mp t' CLOSE CM AL! 3 C'mpa&e AL an$ 3
>4LE CLOSE Get the n#m=e& in t' A/ ?S2 A/ M'9e A/ t' sta*% MO A/!10
M?L B/ M#ltiply A/ 8ith B/ O B/ Sta*% B/
ADD B/!A/
MO A2!012 I4T 512 >M GETF G' t' GETF 4E/T: ;ET Call &et#&n t' MAI4 p&'*e$#&e CLOSE: MO A2!6C2
I4T 512 ;EAD E4DE4D
-
8/13/2019 CO_progs use full programs
23/35
PROGRAME CODE :TITLE T' *he*% 8hethe& the gi9en st&ing is palin$&'me '& n't.
O?T ?T MAC;O MSG Ma*&' ('& message p&inting MO A2! 032 Displays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 Exit t' DOSE4DM
.MODEL SMALL
.STACK 1002
.DATA ST1 DB 1 !10!" Ente& the st&ing : -" ST DB 1 !10!" Gi9en st&ing is n't p'llin$&'me -" ST5 DB 1 !10!" Gi9en st&ing is p'llin$&'me -"
C2A; LABEL B TE De*la&ing the st&ing 9al&ia=le MA/ DB 50 Maxim#m length
ACT DB 0 A*t#al length S DB 50 D? + - , St&ing a&&ay
.CODE ST;I4G ;OC 4EA; MO A/! DATA ;ea$ the $ata pa&t MO DS!A/ in t' DS &egiste&.
O?T ?T MSG1 Call O?T ?T ma*&' ('& MSG1 MO A2!0A2 ;e #est t' &ea$ the st&ing LEA D/!C2A; L'a$ the st&ing 9a&ia=le t' D/ I4T 512 Call ('& DOS /O; A/!A/ Clea& A/ /O; B/!B/ Clea& A/
LEA SI!S L'a$ the st&ing 9a&ia=le t' SI LEA DI!S L'a$ the st&ing 9a&ia=le t' si MO C2!002 Clea& C2 MO CL!ACT CL A*t#al length '( st&ing
LOO 1: I4C DI In*&ease DI LOO LOO 1 D' the l''p #p t' CL 0
MO AL!ACT AL A*t#al length '( st&ing MO BL!052 BL 5 DI BL Di9i$e AL =y BL MO CL!AL CL AL
-
8/13/2019 CO_progs use full programs
24/35
DEC DI De*&ease DI MO AL! SIN AL L'*ati'n '( SI
CM AL! DIN C'mpa&e AL ) L'*ati'n '( SI >E C2ECK I( e #al g' t' C2ECK >M 4OT OL else g' t' 4OT OL C2ECK: I4C SI In*&ease SI DEC DI De*&ease DI MO AL! SIN AL L'*ati'n '( SI CM AL! DIN C'mpa&e AL ) L'*ati'n '( SI >4E 4OT OL I( n' e #al g' t' 4OT OL LOO C2ECK D' the l''p #p t' C2ECK CM CL!0 C'mpa&e CL 8ith 0 >4E 4OT OL O?T ?T ST5 Call O?T ?T ma*&' ('& ST5 >M E/IT
4OT OL: O?T ?T ST Call O?T ?T ma*&' ('& ST5 E/IT: MO A2!6C2 ;e #est t' en$ the exe*#ti'n I4T 512 Call $'s ST;I4G E4DE4D
-
8/13/2019 CO_progs use full programs
25/35
-
8/13/2019 CO_progs use full programs
26/35
E4D
PROGRAME CODE :
TITLE C'n*atinate t8' st&ings
S2OF MAC;O MSG Ma*&' ('& message p&inting MO A2! 032 Displays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 Exit t' DOSE4DM
.MODEL SMALL
.STACK
-
8/13/2019 CO_progs use full programs
27/35
MO AL! SIN M'9e l'*ati'n '( SI int' AL MO DIN!AL Is *ha& n't en$ '( st&ing I4C SI In*&ease SI I4C DI In*&ease DI LOO 7I;ST D' the l''p #p t' CL 0
LEA SI!ST;5 L'a$ the st&ing 9a&ia=le t' SI MO C2!002 Clea& C2 MO CL!ACT1 CL 7i&st st&ing s A*t#al length 4E/T: MO AL! SIN M'9e l'*ati'n '( SI int' AL MO DIN!AL Is *ha& n't en$ '( st&ing I4C SI In*&ease SI I4C DI In*&ease DI LOO 4E/T D' the l''p #p t' CL 0
S2OF MSG Call S2OF ma*&' ('& MSG S2OF ;ES Call S2OF ma*&' ('& ;ES
MO A2!6C2 ;e #est an en$ t' exe*#ti'n I4T 512 Call $'sE4D
-
8/13/2019 CO_progs use full programs
28/35
PROGRAME CODE :
TITLE 7in$ the p&'$#*t '( t8' 6 =it =ina&y n#m=e&s ) p&int th &es#lt in =it
S2OF MAC;O MSG Ma*&' ('& message p&inting
MO A2! 032 Displays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 Exit t' DOSE4DM.MODEL SMALL.STACK 1002.DATA S1 DB 1 !10!" Ente& 1st n#m=e& in 6 =it ('&m -" S5 DB 1 !10!" Ente& 5n$ n#m=e& in 6 =it ('&m -" S DB 1 !10!" &'$#*t '( t8' n#m=e&s -" 4?M DB 0.CODE BI4M?L ;OC 4EA; MO A/! DATA ;ea$ the $ata pa&t MO DS!A/ in t' DS &egiste&.
S2OF S1 Call S2OF ma*&' ('& S1 CALL GETI4 Call GETI4 p&'*e$#&e MO 4?M!BL 4?M BL
S2OF S5 Call S2OF ma*&' ('& S5 CALL GETI4 Call GETI4 p&'*e$#&e
S2OF S Call S2OF ma*&' ('& S MO AL!4?M AL 4?M M?L BL M#ltiply AL 8ith BL MO BL!AL BL AL CALL ;ES?LT Call ;ES?LT p&'*e$#&e
MO A2!6C2 En$ the p&'*ess
I4T 512 Call ('& DOS BI4M?L E4D
GETI4 ;OC 4EA; /O; BL!BL Clea& BL MO CL!062 CL 6 LOO 1: MO A2!012 ;ea$ a Cha&a*te& I4T 512
-
8/13/2019 CO_progs use full programs
29/35
S?B AL! 02 S#=st&a*te 6 (&'m AL S2L BL!1 D' le(t shi(t t' BL 'ne time
ADD BL!AL A$$ AL t' BL LOO LOO 1 D' the l''p #p t' CL 0 ;ET Call &et#&n t' BI4M?L p&'*e$#&e
GETI4 E4D
;ES?LT ;OC 4EA; MO CL!0 2 CL LOO 5: MO A2!052 &int the *ha&a*te& MO DL!002 DL 0 ;CL BL!012 ;'tate 1 =it t' le(t si$e ) st'&es*a&&y
ADC D/! 02 A$$ 6 t' D/ 8ith *a&&y I4T 512LOO LOO 5 D' the l''p #ntill CL 0
;ET Call BI4M?L p&'*e$#&e ;ES?LT E4DE4D
-
8/13/2019 CO_progs use full programs
30/35
PROGRAME CODE :
TITLE 7in$ the s#m '( t8' 6 =it =ina&y n#m=e&s ) p&int th &es#lt in =it
;I4T MAC;O MSG Ma*&' ('& message p&inting MO A2! 032 Displays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 Exit t' DOSE4DM.MODEL SMALL.STACK 1002.DATA S1 DB 1 !10!" Ente& 1st n#m=e& in 6 =it ('&m -" S5 DB 1 !10!" Ente& 5n$ n#m=e& in 6 =it ('&m -"
S DB 1 !10!" S#m '( t8' n#m=e&s -" 4?M DB 0.CODEBI4S?M ;OC 4EA; MO A/! DATA ;ea$ the $ata pa&t MO DS!A/ in t' DS &egiste&.
;I4T S1 Call ;I4T ma*&' ('& S1 CALL I4 ?T Call I4 ?T p&'*e$#&e MO 4?M!BL 4?M BL
;I4T S5 Call ;I4T ma*&' ('& S5 CALL I4 ?T Call I4 ?T p&'*e$#&e
ADD 4?M!BL A$$ BL t' 4?M ;I4T S Call ;I4T ma*&' ('& S MO BL!4?M BL 4?M CALL O?T ?T Call O?T ?T p&'*e$#&e
MO A2!6C2 En$ the p&'*ess I4T 512 Call ('& DOSBI4S?M E4D I4 ?T ;OC 4EA; /O; BL!BL Clea& BL MO CL!062 CL 6 LOO 1: MO A2!012 ;ea$ a Cha&a*te& I4T 512
-
8/13/2019 CO_progs use full programs
31/35
S?B AL! 02 S#=st&a*te 6 (&'m AL S2L BL!1 D' le(t shi(t t' BL 'ne time
ADD BL!AL A$$ AL t' BL LOO LOO 1 D' the l''p #p t' CL 0 ;ET Call &et#&n t' BI4S?M p&'*e$#&e
I4 ?T E4D O?T ?T ;OC 4EA; MO CL!0 2 CL LOO 5: MO A2!052 &int the *ha&a*te& MO DL!002 DL 0 ;CL BL!012 ;'tate 1 =it t' le(t si$e ) st'&es*a&&y ADC D/! 02 A$$ 6 t' D/ 8ith *a&&y
I4T 512LOO LOO 5 D' the l''p #ntill CL 0 ;ET Call BI4S?M p&'*e$#&e O?T ?T E4DE4D
-
8/13/2019 CO_progs use full programs
32/35
PROGRAME CODE :
TITLE T' (in$ the gi9en n#m=e& is eithe& p&ime '& n't
;I4T MAC;O MSG MO A2!032 ;e #est $isplay LEA D/!MSG L'a$ a$$&ess '( title I4T 512 Call t' DOSE4DM;EAD MAC;O 4 MO A2!012 ;ea$s a single *ha&a*te& I4T 512 Call ('& DOS
MO BL!10 BL 10 S?B AL!6 T' get n#m=e& M?L BL M#ltiply AL 8ith 10 MO 4!AL 4 AL MO A2!012 ;ea$ a *ha&a*te& I4T 512 S?B AL!6 S#=st&a*t 6 (&'m AL ADD 4!AL 4 ALE4DM
.MODEL SMALL
.STACK
-
8/13/2019 CO_progs use full programs
33/35
DEC DL $e*&ement DL =y 1 MO BL!052 spe*ial *ase ('& 5 CM BL!4 C'mpa&e BL 8ith 4 >E ES i( e #al g't' ES
4E/T: MO A2!002 *lea& A2 MO AL!4
DI BLCM A2!00 is &emain$e& in A2 e #als t' Pe&'
>E 4O i( s'! g't' 4O I4C BL
CM BL!DL is BL less than '& e #al t' DL >LE 4E/T i( s'! g't' next ES: ;I4T LI4E Call ;I4T ma*&' ('& LI4E ;I4T ST;5 &inting as p&ime ;I4T LI4E
>M LAST g't' last 4O: ;I4T LI4E ;I4T ST; p&inting as n't p&ime ;I4T LI4E LAST:
MO A2!6C2 &e #est an en$ t' p&'g&am exe*#te I4T 512 *all DOS
;IME E4DE4D
-
8/13/2019 CO_progs use full programs
34/35
PROGRAME CODE :
TITLE &inting the &e9e&se '( a st&ingDIS LA MAC;O MSG Ma*&' ('& message p&inting
MO A2! 032 Displays a st&ing LEA D/! MSG msg is l'a$e$ t' D/ &egiste& I4T 512 Exit t' DOSE4DM.MODEL SMALL.STACK 4E 4E/T I( s'! g't' 4E/T
LEA B/!S5 A$$&ess '( S5 is gi9en t' B/ LAST: MO AL! SIN M'9e SI int' B/ MO B/N!AL DEC SI De*&ement SI =y 1 I4C B/ In*&ement B/ =y 1
LOO LAST DIS LA ST;5 Call DIS LA ma*&' ('& ST;5 DIS LA LI4E Call DIS LA ma*&' ('& LI4E DIS LA S5 &inting S5 st&ing +;e9e&se$, MO A2!6C2 ;e #est an en$ t' exe*#ti'n
-
8/13/2019 CO_progs use full programs
35/35
I4T 512 Call $'sE4D