D e s c r i p t i o n   o f   f u n c t i o n s   i n s i d e   F A S M . D L L 
 
 ?8A0=85  DC=:F89  F A S M . D L L 
 
 F A S M . D L L K00pen0fg0Y00
 
 
 
 f a s m _ G e t V e r s i o n ( ) 
 
  0R e t u r n s   d o u b l e   w o r d   c o n t a i n g   m a j o r   v e r s i o n   i n   l o w e r   1 6   b i t s ,   a n d   m i n o r   v e r s i o n   i n   t h e   h i g h e r   1 6   b i t s . 
 
  0>72@0I05B  42>9=>5  A;>2>( d w o r d )   A>45@60I55  >A=>2=CN  G0BL  25@A88  2  <;04H8E  1 6   18B0E,   8  ?>425@A8N  2  AB0H8E  1 6   18B0E. 
 
  0D w o r d 0ԏW0~0Y001 6 000NMOo0͑j000000juS+T0~0Y001 6 000
NMOo00000000juS+T0~0Y00
 
 
 
 f a s m _ A s s e m b l e ( l p S o u r c e , l p M e m o r y , c b M e m o r y S i z e , n P a s s e s L i m i t , h D i s p l a y P i p e ) 
 
  0A s s e m b l e s   t h e   g i v e n   s o u r c e ,   u s i n g   t h e   p r o v i d e d   m e m o r y   b l o c k   a s   a   f r e e   s t o r a g e   s p a c e ( w h i c h   i s   a l s o   t o   c o n t a i n   g e n e r a t e d   o u t p u t ) . 
 
  0AA5<1;8@C5B  ?5@540==K9  8AE>4=K9  :>4,   8A?>;L7CO  ?5@540==K9  1;>:  ?0<OB8  :0:  @01>G55  ?@>AB@0=AB2>( 2K2>4  B0:65  1C45B  =0E>48BLAO  2  =Q<) . 
 
  0000000000W0~0Y000000000D00k00000000L0!ng0M000d0K0D0~0Y0]0n00000000n0~00-Nk0QRL0B00~0Y0	0
 
  0T h e   l p S o u r c e   s h o u l d   c o n t a i n   a   p o i n t e r   t o   z e r o - e n d e d   s o u r c e   t e x t ( p a n s i c h a r ) . 
 
  0l p S o u r c e   4>;65=  A>45@60BL  C:070B5;L  =0  >:0=G820NI89AO  =C;Q<( z e r o - e n d e d )   8AE>4=K9  :>4( p a n s i c h a r ) . 
 
  0l p S o u r c e o0000x00000g0Y0p a n s i c h a r 	0B}00n0eW[n0$Po000g0Y00
 
  0T h e   l p M e m o r y   s h o u l d   b e   a   p o i n t e r   t o   t h e   m e m o r y   b l o c k   a n d   c b M e m o r y S i z e   s h o u l d   c o n t a i n   i t s   s i z e .   I n   t h e   b e g i n n i n g   o f   t h i s   m e m o r y   b l o c k   t h e   F A S M _ S T A T E ( T F A S M _ S T A T E   i n   D e l p h i )   s t r u c t u r e   w i l l   r e s i d e .   T h e   a s s e m b l e r   d o e s n ' t   a l l o c a t e   a n y   m e m o r y   b e s i d e   t h i s   b l o c k ,   i f   i t   i s   n o t   e n o u g h   f o r   i t s   p u r p o s e s ,   t h e   f u n c t i o n   r e t u r n   F A S M _ O U T _ O F _ M E M O R Y . 
 
  0l p M e m o r y   4>;65=  A>45@60BL  C:070B5;L  =0  1;>:  ?0<OB8, 0  c b M e m o r y S i z e   4>;65=  A>45@60BL  53>  @07<5@.   =0G0;5  MB>3>  1;>:0  1C45B  A>740=0  AB@C:BC@0  F A S M _ S T A T E ( T F A S M _ S T A T E   2  D e l p h i ) .   AA5<1;5@  =5  2K45;O5B  ?0<OBL  2=5  MB>3>  1;>:0,   5A;8  5Q  =54>AB0B>G=>  DC=:F8O  25@=QB  F A S M _ O U T _ O F _ M E M O R Y . 
 
  0l p M e m o r y o0000x00000000g0Y00c b M e m o r y S i z e o0]0n00000000n0000g0Y000000000n0o0X00k0F A S M _ S T A T E n00000L0B0D0~0Y0D e l p h i n0_00k0T F A S M _ S T A T E g0Y0	0000000o0000}n0rR0S_f00LD0~0[0000000
NY0L0peL0F A S M _ O U T _ O F _ M E M O R Y 0ԏW0~0Y00
 
  0T h e   n P a s s e s L i m i t   s h o u l d   b e   a   v a l u e   i n   r a n g e   f r o m   1   t o   6 5 5 3 6 ,   d e f i n i n g   t h e   m a x i m u m   n u m b e r   o f   p a s s e s   t h e   a s s e m b l e r   c a n   p e r f o r m   i n   o r d e r   t o   g e n e r a t e   t h e   c o d e ( t h e   r e c o m m e n d e d   v a l u e   i s   1 0 0 ) .   I f   t h e   l i m i t   i s   r e a c h e d ,   t h e   f u n c t i o n   r e t u r n   F A S M _ C A N N O T _ G E N E R A T E _ C O D E . 
 
  0n P a s s e s L i m i t   4>;65=  1KBL  2  480?>7>=5  >B  1   4>  6 5 5 3 6 .   =  704QB  <0:A8<0;L=>5  :>;8G5AB2>  ?@>E>4>2,   :>B>@K5  0AA5<1;5@  <>65B  2K?>;=8BL  2>  2@5<O  35=5@0F88  :>40  ( @5:><5=4>20=0O  25;8G8=0  1 0 0 ) .   A;8  ;8<8B  4>AB83=CB,   DC=:F8O  25@=QB  F A S M _ C A N N O T _ G E N E R A T E _ C O D E . 
 
  0n P a s s e s L i m i t o0K00~0g0$PL0B00~0Y00n P a s s e s L i m i t o0 g'Yn000000n0kg0Y000000n0$P	.  g'Yn0k00RTY00L0peL0F A S M _ C A N N O T _ G E N E R A T E _ C O D E 0ԏW0~0Y00
 
  0T h e   h D i s p l a y P i p e   s h o u l d   c o n t a i n   h a n d l e   o f   t h e   p i p e ,   t o   w h i c h   t h e   o u t p u t   o f   D I S P L A Y   d i r e c t i v e s   w i l l   b e   w r i t t e n .   I f   t h i s   p a r a m e t e r   i s   0 ,   a l l   t h e   d i s p l a y   w i l l   g e t   d i s c a r d e d . 
 
  0h D i s p l a y P i p e   4>;65=  A>45@60BL  h a n d l e   p i p e ' 0,   2  :>B@>@K9  1C45B  70?8A0=  2K2>4  =0  M:@0=.   A;8  MB>  ?@0<5B@  @025=  0 ,   25AL  2K2>4  1C45B  >B1@>H5=. 
 
  0h D i s p l a y P i p e k0p i p e n0h a n d l e L0B00~0Y00p i p e o0h:yn0QR0h D i s p l a y P i p e L000L0QRL0B00~0[000
 
  0I f   t h e   a s s e m b l y   i s   s u c c e s s f u l ,   f u n c t i o n   r e t u r n s   F A S M _ O K   v a l u e   a n d   f i l l s   t h e   o u t p u t _ d a t a   a n d   o u t p u t _ l e n g t h   f i e l d s   o f   t h e   F A S M _ S T A T E   s t r u c t u r e ( w h i c h   r e s i d e s   a t   t h e   b e g i n n i n g   o f   p r o v i d e d   m e m o r y   b l o c k ) . 
 
  0A;8  0AA5<1;8@>20=85  ?@>94QB  C40G=>,   DC=:F8O  25@=QB  F A S M _ O K   8  70?>;=8B  o u t p u t _ d a t a   8  o u t p u t _ l e n g t h   2  AB@C:BC@5  F A S M _ S T A T E ( :>B>@0O  =0E>48BAO  2  =0G0;5  2K45;==>3>  1;>:0  ?0<OB8) . 
 
  000000o0bRY00L0ԏL0F A S M _ O K g0Y00F A S M _ S T A T E 0000n0o u t p u t _ d a t a h0o u t p u t _ l e n g t h L0B00~0Y0S00o00000000n0R0f0k0g0Y0	0
 
  0I f   t h e   a s s e m b l y   f a i l e d ,   f u n c t i o n   r e t u r n s   o n e   o f   t h e   o t h e r   g e n e r a l   c o n d i t i o n s / e r r o r s   c o d e s ( s e e   " G e n e r a l   e r r o r s   a n d   c o n d i t i o n s "   i n   F a s m 4 D e l p h i . p a s ) .   I f   i f   e r r o r   c o d e   i s   F A S M _ E R R O R ,   i t   m e a n s   t h a t   a n   e r r o r   c a u s e d   b y   a   s p e c i f i c   p l a c e   i n   s o u r c e   o c c u r e d ,   t h e n   t h e   e r r o r _ c o d e   a n d   e r r o r _ l i n e   f i e l d s   o f   F A S M _ S T A T E   a r e   f i l l e d ,   f i r s t   o n e   w i t h   d e t a i l e d   e r r o r   c o d e ( s e e   " E r r o r   c o d e s   f o r   F A S M _ E R R O R   c o n d i t i o n "   i n   F a s m 4 D e l p h i . p a s ) ,   a n d   t h e   s e c o n d   o n e   w i t h   p o i n t e r   t o   a   s t r u c t u r e   c o n t a i n i n g   d a t a   a b o u t   l i n e   t h a t   c a u s e d   t h e   e r r o r ( s e e   " T L I N E _ H E A D E R "   i n   F a s m 4 D e l p h i . p a s ) . 
 
  0A;8  0AA5<1;8@>20=85  =5C40;>AL,   DC=:F8O  25@=QB  >48=  87  4@C38E  >A=>2=KE  :>4>2  >H81>:( A<.   " G e n e r a l   e r r o r s   a n d   c o n d i t i o n s "   2  F a s m 4 D e l p h i . p a s ) .   A;8  :>4  >H81:8  -   F A S M _ E R R O R ,   MB>  7=0G8B  GB>  >H81:0  ?@>87>H;0  2  >?@545;Q==><  <5AB5  :>40,   B>340  ?>;O  e r r o r _ c o d e   a n d   e r r o r _ l i n e   F A S M _ S T A T E ' 0  1C4CB  70?>;=5=K,   ?5@2>5  87  =8E  1C45B  A>45@60BL  45B0;L=K9  :>4  >H81:8( A<.   " E r r o r   c o d e s   f o r   F A S M _ E R R O R   c o n d i t i o n "   2  F a s m 4 D e l p h i . p a s ) , 0  2B>@0O  -   C:070B5;L( p o i n t e r )   =0  AB@C:BC@C  A>45@60ICN  8=D>@<0F8N  >  AB@>:5  2  :>B@>9  ?@>87>H;0  >H81:0( A<.   " T L I N E _ H E A D E R "   2  F a s m 4 D e l p h i . p a s ) . 
 
  000000o0bRW0j0D0L0peL00000000ԏW0~0Y0F a s m 4 D e l p h i . p a s x00G e n e r a l  0e r r o r s  0a n d  0c o n d i t i o n s 
000	0F A S M _ E R R O R o0000x00000asTY000]00K00F A S M _ S T A T E n0e r r o r _ c o d e h0e r r o r _ l i n e L0B00~0Y00e r r o r _ c o d e o0Nju000000F a s m 4 D e l p h i . p a s x00E r r o r  0c o d e s  0f o r  0F A S M _ E R R O R  0c o n d i t i o n 
000	0e r r o r _ l i n e o0000n0eW[Rn00000x00000F a s m 4 D e l p h i . p a s x00T L I N E _ H E A D E R 
000	0
 
 f a s m _ A s s e m b l e F i l e ( l p S o u r c e F i l e , l p M e m o r y , c b M e m o r y S i z e , n P a s s e s L i m i t , h D i s p l a y P i p e ) 
 
  0T h i s   f u n c t i o n   p e r f o r m s   i d e n t i c a l l y   t o   f a s m _ A s s e m b l e ,   e x c e p t   t h a t   i t   t a k e s   t h e   l p S o u r c e F i l e   p a r a m e t e r   i n   p l a c e   o f   l p S o u r c e ,   a n d   i t   s h a l l   c o n t a i n   t h e   p o i n t e r   t o   z e r o - e n d e d   p a t h   t o   f i l e   c o n t a i n i n g   t h e   s o u r c e   t o   a s s e m b l e ( p a n s i c h a r ) . 
 
  0-B0  DC=:F8O  @01>B05B  845=B8G=>  f a s m _ A s s e m b l e ,   =>  2  >B;8G88  >B  =5Q  ?@8=8<05B  ?0@0<5B@  l p S o u r c e F i l e   2<5AB>  l p S o u r c e .   -B>B  ?0@0<5B@  4>;65=  A>45@60BL  C:070B5;L( p o i n t e r )   =0  >:0=G820NI89AO  =C;Q<( z e r o - e n d e d )   ?CBL  4>  D09;0  A>45@60I53>  8AE>4=K9  :>4  4;O  0AA5<1;8@>20=8O( p a n s i c h a r ) . 
 
  0S0n0peo0TX0k0f a s m _ A s s e m b l e g0Y00g000 Nju00000o0l p S o u r c e F i l e B00~0Y00l p S o u r c e F i l e o00000000n0
TMRx00000g0Y0p a n s i c h a r 	0B}00n0eW[n0$Po000g0Y00
 
 
 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 
 D e s c r i p t i o n   o f   s t r u c t u r e s   u s e d   i n   F A S M . D L L 
 
 ?8A0=85  AB@C:BC@  8A?>;L7C5<KE  F A S M . D L L 
 
 F A S M . D L L K00000000n0fg0Y00
 
 
 
  0T h e   f o l l o w i n g   s t r u c t u r e   r e s i d e s   a t   t h e   b e g i n n i n g   o f   m e m o r y   b l o c k   p r o v i d e d   t o   t h e   f a s m _ A s s e m b l e   f u n c t i o n .   T h e   c o n d i t i o n   f i e l d   c o n t a i n s   t h e   s a m e   v a l u e   a s   t h e   o n e   r e t u r n e d   b y   f u n c t i o n . 
 
  0!;54CNI0O  AB@C:BC@0  =0E>48BAO  2  =0G0;5  1;>:0  ?0<OB8  ?5@540205<>3>  2  f a s m _ A s s e m b l e .   >;5  c o n d i t i o n   A>45@68B  B>65  7=0G5=85  :>B>@>5  2>72@0I05BAO  DC=:F859. 
 
  0f a s m _ A s s e m b l e n0_00k00000000n0R0f0k0S0n0000000L0B00~0Y00c o n d i t i o n o0TX0pen0ԏg0Y00
 
  0 0W h e n   f u n c t i o n   r e t u r n s   F A S M _ O K   c o n d i t i o n ,   t h e   o u t p u t _ l e n g t h   a n d   o u t p u t _ d a t a   f i e l d s   a r e   f i l l e d   -   w i t h   p o i n t e r   t o   g e n e r a t e d   o u t p u t ( s o m e w h e r e   w i t h i n   t h e   p r o v i d e d   m e m o r y   b l o c k )   a n d   t h e   c o u n t   o f   b y t e s   s t o r e d   t h e r e . 
 
  0 0>340  DC=:F8O  2>72@0I05B  F A S M _ O K ,   ?>;O  o u t p u t _ l e n g t h   8  o u t p u t _ d a t a   70?>;=5=K  C:070B5;5<( p o i n t e r )   =0  @57C;LB0B  0AA5<1;8@>20=8O( >=  =0E>48BAO  2=CB@8  1;>:0  ?0<OB8  2=CB@8  1;>:0  ?0<OB8)   8  4;8==>9  MB>3>  1;>:0  ?0<OB8  A>>B25BAB25==>. 
 
  0 0ԏL0F A S M _ O K B00~0Y0L0o u t p u t _ l e n g t h h0o u t p u t _ d a t a o000000n0ԏx00000S00L00000000n0~00-Nk0	h0QRn0000g0Y00
 
  0 0W h e n   f u n c t i o n   r e t u r n s   F A S M _ E R R O R ,   t h e   e r r o r _ c o d e   i s   f i l l e d   w i t h   t h e   c o d e   o f   s p e c i f i c   e r r o r ( s e e   " E r r o r   c o d e s   f o r   F A S M _ E R R O R   c o n d i t i o n "   i n   F a s m 4 D e l p h i . p a s )   t h a t   h a p p e n e d   a n d   e r r o r _ l i n e   i s   a   p o i n t e r   t o   t h e   L I N E _ H E A D E R   s t r u c t u r e ,   p r o v i d i n g   i n f o r m a t i o n   a b o u t   t h e   l i n e   t h a t   c a u s e d   t h e   e r r o r . 
 
  0 0>340  DC=:F8O  2>72@0I05B  F A S M _ E R R O R   -   e r r o r _ c o d e   A>45@68B  45B0;L=K9  :>4  >H81:8( A<.   " E r r o r   c o d e s   f o r   F A S M _ E R R O R   c o n d i t i o n "   2  F a s m 4 D e l p h i . p a s ) ,   0  e r r o r _ l i n e   -   C:070B5;L( p o i n t e r )   =0  AB@C:BC@C  L I N E _ H E A D E R ,   ?5@540NICN  8=D>@<0F8N  >  AB@>:5  2  :>B>@>9  ?@>87>H;0  >H81:0. 
 
  0 0ԏL0F A S M _ E R R O R B00~0Y0L0e r r o r _ c o d e o0Njug0Y0F a s m 4 D e l p h i . p a s x00E r r o r  0c o d e s  0f o r  0F A S M _ E R R O R  0c o n d i t i o n 
000	0e r r o r _ l i n e o0L I N E _ H E A D E R n00000x000000L I N E _ H E A D E R o0eW[Rn0000000000B00~0Y00
 
 
 
 T F A S M _ S T A T E = r e c o r d 
 
     c o n d i t i o n : I n t 3 2 ; 
 
     c a s e   b y t e   o f 
 
     0 : ( e r r o r _ c o d e : I n t 3 2 ; 
 
           e r r o r _ l i n e : P L I N E _ H E A D E R ; ) ; 
 
     1 : ( o u t p u t _ l e n g t h : c a r d i n a l ; 
 
           o u t p u t _ d a t a : p o i n t e r ; ) ; 
 
 e n d ; 
 
 
 
  0T h e   f o l l o w i n g   s t r u c t u r e   h a s   t w o   v a r i a n t s   -   i t   e i t h e r   d e f i n e s   t h e   l i n e   t h a t   w a s   l o a d e d   d i r e c t l y   f r o m   s o u r c e ,   o r   t h e   l i n e   t h a t   w a s   g e n e r a t e d   b y   m a c r o i n s t r u c t i o n .   F i r s t   c a s e   h a s   t h e   h i g h e s t   b i t   o f   l i n e _ n u m b e r   s e t   t o   0 ,   w h i l e   t h e   s e c o n d   c a s e   h a s   t h i s   b i t   s e t . 
 
  0!;54CNI0O  AB@C:BC@0  8<55B  420  20@80=B0  -   >=0  ;81>  >?@545;O5B  AB@>:C,   :>B@0O  1K;0  703@C65=0  =5?>A@54AB25==>  87  8AE>4=>3>  :>40,   ;81>  ;8=8N, :>B>@0O  1K;0  A35=5@8@>20=0  <0:@>8=AB@C:F859.     ?5@2><  A;CG05  AB0@H89  18B  l i n e _ n u m b e r ' 0  CAB0=>2;5=  2  0 ,   2  B>  2@5<O  :0:  2>  2B>@><  MB>B  18B  CAB0=>2;5=  2  1 . 
 
  0S0n00000o0Nd0n000000000 Nju00000o0T L I N E _ H E A D E R L0000k0eW[R0B00~0Y00Nju00000o0T L I N E _ H E A D E R L0000}TNn0eW[R0B00~0Y00 Nju00000o0l i n e _ n u m b e r n0000
NMOk0g0Y00Nju00000o0l i n e _ n u m b e r n0000
NMOk0g0Y00
 
  0 0I n   t h e   f i r s t   c a s e ,   t h e   f i l e _ p a t h   f i e l d   c o n t a i n s   p o i n t e r   t o   t h e   p a t h   o f   s o u r c e   f i l e ( e m p t y   s t r i n g   i f   i t ' s   t h e   s o u r c e   t h a t   w a s   p r o v i d e d   d i r e c t l y   t o   f a s m _ A s s e m b l e   f u n c t i o n ) ,   t h e   l i n e _ n u m b e r   i s   t h e   n u m b e r   o f   l i n e   w i t h i n   t h a t   f i l e ( s t a r t i n g   f r o m   1 )   a n d   t h e   f i l e _ o f f s e t   f i e l d   c o n t a i n s   t h e   o f f s e t   w i t h i n   t h e   f i l e   w h e r e   t h e   l i n e   s t a r t s . 
 
  0 0  ?5@2><  A;CG05,   ?>;5  f i l e _ p a t h   A>45@68B  C:070B5;L( p o i n t e r )   =0  ?CBL  4>  D09;0  A  8AE>4=K<  :>4><( ?CAB0O  AB@>:0  >7=0G05B,   GB>  MB>  8AE>4=K9  :>4  ?5@540==K9  2  f a s m _ A s s e m b l e ) ,   l i n e _ n u m b e r   -   =><5@  AB@>:8  2  MB><  D09;5( AG8B0O  A  1 ) ,   0  ?>;5  f i l e _ o f f s e t   A>45@68B  A<5H5=85  2  D09;5,   =0  :>B>@><  =0G8=05BAO  AB@>:0. 
 
  0 0 Nju00000o0f i l e _ p a t h L0000n00000
Tx00000zzeW[RL0l p S o u r c e g0Y0) 0l i n e _ n u m b e r o0eW[Rn0juS Njuo0	0f i l e _ o f f s e t o0eW[Rn0R0f0k0eW[n0juSg0Y00
 
  0 0I n   t h e   s e c o n d   c a s e   t h e   m a c r o _ c a l l i n g _ l i n e   f i e l d   c o n t a i n s   t h e   p o i n t e r   t o   L I N E _ H E A D E R   s t r u c t u r e   f o r   t h e   l i n e   w h i c h   c a l l e d   t h e   m a c r o i n s t r u c t i o n ,   a n d   t h e   m a c r o _ l i n e   f i e l d   c o n t a i n s   t h e   p o i n t e r   t o   L I N E _ H E A D E R   s t r u c t u r e   f o r   t h e   l i n e   w i t h i n   t h e   d e f i n i t i o n   o f   m a c r o i n s t r u c t i o n ,   w h i c h   g e n e r a t e d   t h i s   o n e . 
 
  0 0>  2B>@><  A;CG05  ?>;5  m a c r o _ c a l l i n g _ l i n e   A>45@68B  C:070B5;L( p o i n t e r )   =0  AB@C:BC@C  T L I N E _ H E A D E R   4;O  AB@>:8,   :>B>@CN  2K7K205B  <0:@>8=AB@C:F8O,   0  ?>;5  m a c r o _ l i n e   A>45@68B  C:070B5;L( p o i n t e r )   =0  AB@C:BC@C  T L I N E _ H E A D E R   4;O  AB@>:8,   2  :>B>@>9  =0E>48BAO  <0:@>8=AB@C:F8O,   C:07K20NI0O  =0  B5:CICN. 
 
  0 0 Nju00000o0m a c r o _ c a l l i n g _ l i n e L0T L I N E _ H E A D E R n00000x00000n0_00k0d0N0n0000}TNn0|Ts0g0Y00m a c r o _ l i n e L0T L I N E _ H E A D E R n00000x00000n0_00k0MRn0000}TNn0|Ts0g0Y0. 
 
 
 
 T L I N E _ H E A D E R = r e c o r d 
 
     f i l e _ p a t h : P A n s i C h a r ; 
 
     l i n e _ n u m b e r : c a r d i n a l ; 
 
     c a s e   b y t e   o f 
 
         0 : ( f i l e _ o f f s e t : c a r d i n a l ) ; 
 
         1 : ( m a c r o _ c a l l i n g _ l i n e : ^ T L I N E _ H E A D E R ; 
 
             m a c r o _ l i n e : ^ T L I N E _ H E A D E R ; ) ; 
 
 e n d ; 