8AB8=3  1 9 . 2 8 .    57C;LB0B  :><?8;OF88  ?@8<5@0  87  8AB8=30  1 9 . 2 6   
 
                               A  ?>445@6:>9  A>?@>F5AA>@0
 
 
 
 P R O G R A M 	 p r o c   n e a r 
 
 
 
   	 c a l l 	 I N I T T A S K 
 
   	 c a l l 	 @ _ _ S y s t e m I n i t $ q v ) 	 ;   _ _ S y s t e m I n i t ( v o i d ) 
 
   	 ;   =8F80;878@C5<  <>4C;L  S y s t e m 
 
 
 
   	 c a l l 	 @ _ _ I n i t E M 8 6 $ q v 	 ;   I n i t i a l i z e   s o f t w a r e   e m u l a t o r 
 
   	 ;   0459AB2C5<  M<C;OB>@  A>?@>F5AA>@0
 
 
 
   	 c a l l 	 @ _ _ W I N C R T I n i t $ q v   	 ;   _ _ W I N C R T I n i t ( v o i d ) 
 
   	 ;   =8F80;878@C5<  <>4C;L  W I N C R T 
 
 
 
   	 p u s h 	 b p 	 	 
 
   	 m o v 	 b p ,   s p 	 	 
 
   	 ;   B:@K205<  :04@  AB5:0
 
 
 
   	 x o r 	 a x ,   a x 	 	 
 
   	 c a l l 	 @ _ _ S t a c k C h e c k $ q 4 W o r d   	 ;   S t a c k   o v e r f l o w   c h e c k   ( A X ) 
 
   	 ;   @>25@:0  AB5:0  =0  ?5@5?>;=5=85	 
 
 
 
   	 m o v 	 w o r d _ 2 1 C 0 ,   0 E C 8 3 h 	 	 
 
   	 m o v 	 w o r d _ 2 1 C 2 ,   0 B 8 5 1 h 	 	 
 
   	 m o v 	 w o r d _ 2 1 C 4 ,   5 5 1 E h 	 	 
 
   	 m o v 	 w o r d _ 2 1 C 6 ,   3 D 8 3 h 	 	 
 
   	 m o v 	 w o r d _ 2 1 C 8 ,   0 D 7 0 A h 	 	 
 
   	 m o v 	 w o r d _ 2 1 C A ,   7 8 A 3 h 	 	 
 
   	 ;   >:0  <K  =5  <>65<  >?@545;8BL  B8?  8=8F80;878@C5<KE  ?5@5<5==KE. 
 
   	 ;   -B>  A  @02=K<  CA?5E><  <>65B  1KBL  8  W O R D   8  R e a l 
 
 
 
   	 m o v 	 a x ,   w o r d _ 2 1 C 0 	 	 
 
   	 m o v 	 b x ,   w o r d _ 2 1 C 2 	 	 
 
   	 m o v 	 d x ,   w o r d _ 2 1 C 4 	 	 
 
   	 c a l l 	 @ E x t e n d e d $ q 4 R e a l   	 ;   C o n v e r t   R e a l   t o   E x t e n d e d 
 
   	 ;     2>B  B5?5@L  <K  ?5@5405<  w o r d _ 2 1 C 0 ,   w o r d _ 2 1 C 2   8  w o r d _ 2 1 C 4   DC=:F88, 
 
   	 ;   ?@5>1@07CNI89  R e a l   2  E x t e n d   A  703@C7:>9  ?>A;54=53>  2  AB5:  A>?@>F5AA>@0, 
 
   	 ;   7=0G8B,   w o r d _ 2 1 C 0      w o r d _ 2 1 C 4   MB>  ?5@5<5==0O  B8?0  R e a l . 
 
 
 
   	 m o v 	 a x ,   w o r d _ 2 1 C 6 	 	 
 
   	 m o v 	 b x ,   w o r d _ 2 1 C 8 	 	 
 
   	 m o v 	 d x ,   w o r d _ 2 1 C A 	 	 
 
   	 c a l l 	 @ E x t e n d e d $ q 4 R e a l   	 ;   C o n v e r t   R e a l   t o   E x t e n d e d 
 
   	 ;   =0;>38G=>     w o r d _ 2 1 C 6      w o r d _ 2 1 C A      ?5@5<5==0O  B8?0  R e a l 
 
 
 
   	 w a i t 	 	 	 
 
   	 ;   45<  ?>:0  A>?@>F5AA>@  =5  70:>=G8B  A2>N  @01>BC. 
 
 	 	 	 	 
 
   	 f a d d p 	 s t ( 1 ) ,   s t 	 	 
 
   	 ;   !:;04K205<  420  G8A;0  B8?0  e x t e n d e d ,   ;560I8E  =0  25@H8=5  AB5:0  
 
   	 ;   A>?@>F5AA>@0  A  A>E@0=5=85<  @57C;LB0B0  2  B><  65  A0<><  AB5:5. 
 
 
 
   	 c a l l 	 @ R e a l $ q 8 E x t e n d e d   	 ;   C o n v e r t   E x t e n d e d   t o   R e a l 
 
   	 ;   @5>1@07C5<  E x t e n d e d   2  R e a l 
 
   	 ;   @3C<5=B  ?5@5405BAO  G5@57  AB5:  A>?@>F5AA>@0,   0  2>72@0I05BAO  2
 
   	 ;   @538AB@0E  A X   B X   D X . 
 
 
 
   	 p u s h 	 d x 	 	 
 
   	 p u s h 	 b x 	 	 
 
   	 p u s h 	 a x 	 	 
 
   	 ;    538AB@K  A X ,   B X   8  D X   A>45@60B  7=0G5=85  B8?0  R e a l , 
 
   	 ;   A;54>20B5;L=>  ?@>B>B8?  ?@>F54C@K  2K3;O48B  B0:: 
 
   	 ;   M y P r o c ( a : R e a l ) ; 
 
 
 
   	 c a l l 	 M y P r o c 	 	 
 
 	 	 	 	 
 
   	 p o p 	 b p 	 	 
 
   	 x o r 	 a x ,   a x 	 	 
 
   	 c a l l 	 @ H a l t $ q 4 W o r d 	 ;   H a l t ( W o r d ) 
 
 P R O G R A M 	 e n d p 	 	 
 
 
 
 M y P r o c 	 p r o c   n e a r 	 ;   C O D E   X R E F :   P R O G R A M + 6 D   p 
 
 	 	 	 	 
 
 a r g _ 0   =   w o r d   p t r     4 
 
 a r g _ 2   =   w o r d   p t r     6 
 
 a r g _ 4   =   w o r d   p t r     8 
 
 ;   0:  <K  C65  ?><=8<,   MB8  B@8  0@3C<5=B0     =0  A0<><  45;5  
 
 ;   >48=  0@3C<5=B  B8?0  R e a l . 
 
 
 
   	 p u s h 	 b p 	 	 
 
   	 m o v 	 b p ,   s p 	 	 
 
   	 ;   B:@K205<  :04@  AB5:0
 
 
 
   	 x o r 	 a x ,   a x 	 	 
 
   	 c a l l 	 @ _ _ S t a c k C h e c k $ q 4 W o r d   	 ;   S t a c k   o v e r f l o w   c h e c k   ( A X ) 
 
   	 ;   @>25@:0  AB5:0  =0  ?5@5?>;=5=85
 
 
 
   	 m o v 	 d i ,   o f f s e t   u n k _ 2 3 9 6 	 	 
 
   	 p u s h 	 d s 	 	 
 
   	 p u s h 	 d i 	 	 
 
   	 ;   0=>A8<  2  AB5:  C:070B5;L  =0  1CD5@  4;O  2K2>40  AB@>:8
 
 
 
   	 m o v 	 a x ,   [ b p + a r g _ 0 ] 	 	 
 
   	 m o v 	 b x ,   [ b p + a r g _ 2 ] 	 	 
 
   	 m o v 	 d x ,   [ b p + a r g _ 4 ] 	 	 
 
   	 c a l l 	 @ E x t e n d e d $ q 4 R e a l   	 ;   C o n v e r t   R e a l   t o   E x t e n d e d 
 
   	 ;   @5>1@07C5<  R e a l   2  E x t e n d e d 
 
 
 
   	 m o v 	 a x ,   1 7 h 	 	 
 
   	 p u s h 	 a x 	 	 
 
   	 ;   (8@8=0  2K2>40  0 E1 7   7=0:>2
 
 
 
   	 m o v 	 a x ,   0 F F F F h 	 	 
 
   	 p u s h 	 a x 	 	 
 
   	 ;   >;8G5AB2>  7=0:>2  ?>A;5  70?OB>9     2A5  GB>  5ABL,   2A5  8  2K2>48BL
 
 
 
   	 c a l l 	 @ W r i t e $ q m 4 T e x t 8 E x t e n d e d 4 W o r d t 3   	 	 
 
 	 	 ;   W r i t e ( v a r   f ;   v :   E x t e n d e d { s t ( 0 ) ;   w i d t h   d e c i m a l s :   W o r d ) 
 
   	 ;   K2>4  25I5AB25==>3>  G8A;0  A>  AB5:0  A>?@>F5AA>@0  2  1CD5@
 
 
 
   	 c a l l 	 @ W r i t e L n $ q m 4 T e x t   	 ;   W r i t e L n ( v a r   f :   T e x t ) 
 
   	 ;   5G0BL  AB@>:8  87  1CD5@0
 
 
 
   	 c a l l 	 @ _ _ I O C h e c k $ q v 	 ;   E x i t   i f   e r r o r 
 
   	 p o p 	 b p 	 	 
 
   	 r e t n 	 6 	 	 
 
 M y P r o c 	 e n d p 	 	 
 
 