1                                  	;; ----===*******===----
     2                                  	%INCLUDE 'PROLOG.NSM' 
     3                              <1> ;;=======================================================================75
     4                              <1> ;; File: PROLOG.NSM  By: s_dubrovich@yahoo.com
     5                              <1> ;; Last: Sun 14 Aug 2011 03:54:18 PM CDT
     6                              <1> ;; Prev: 08-May-11 10:12:47 AM, Tue 26 Jul 2011 09:32:58 PM CDT
     7                              <1> ;; Init: 10-Jan-10 10:11:21 PM
     8                              <1> ;; Vers: 4r2
     9                              <1> ;; Note: target gnuLinux, nasm -f elf
    10                              <1> ;; Sun 14 Aug 2011 03:54:18 PM CDT - v.4r2 chg main: to _main for
    11                              <1> ;;  ccna32 v.0r3
    12                              <1> ;;=======================================================================75
    13                              <1> ;;  Build using these commands:
    14                              <1> ;;    nasm -f elf -o file.o file.nsm
    15                              <1> ;;    ld -o file file.o
    16                              <1> ;; -or- if linking in an extern..
    17                              <1> ;;    ld --dynamic-linker /lib/ld-linux.so.2 -lc -o file file.o
    18                              <1> ;;  ex. extern puts
    19                              <1> ;;
    20                              <1> ;;  To run: prepend ./ to /file
    21                              <1> ;;=======================================================================75
    22                              <1> ;; -= sys functions =-
    23                              <1> 
    24                              <1> 	SYS_READ_FN	equ 3
    25                              <1> 	SYS_WRITE_FN	equ 4
    26                              <1> 
    27                              <1> 	FP_STD_ERR	equ 3
    28                              <1> 	FP_STD_IN	equ 0
    29                              <1> 	FP_STD_OUT	equ 1
    30                              <1> 
    31                              <1> ;;=======================================================================75
    32                              <1> ;; CPU PENTIUM
    33                              <1> 
    34                              <1>   [SECTION .text]
    35                              <1> 
    36                              <1> global 	_start
    37                              <1> 
    38                              <1> _start:
    39 00000000 90                  <1>   nop				;; no-op for gdb...
    40                              <1> 
    41 00000001 BC[C0220000]        <1>   mov  esp, stacktop
    42                              <1> 
    43                              <1> ;; -= MAIN =-
    44                              <1> 
    45 00000006 E822000000          <1>   call _main	;; internally generated label with leading underscore for
    46                              <1> 		;; main()
    47                              <1> 
    48                              <1> Done:
    49 0000000B B804000000          <1>   mov  eax, SYS_WRITE_FN	;; sys_write fn
    50 00000010 BB01000000          <1>   mov  ebx, FP_STD_OUT		;; Specify File Descriptor stdout
    51 00000015 B9[08000000]        <1>   mov  ecx, Msg			;; offset, message
    52 0000001A BA20000000          <1>   mov  edx, Msg_Len		;; length, message
    53 0000001F CD80                <1>   int  80h
    54                              <1> 
    55                              <1> Exit:
    56 00000021 B801000000          <1>   mov  eax, 1			;; Code for Exit Syscall
    57 00000026 BB00000000          <1>   mov  ebx, 0			;; Return a code of zero	
    58 0000002B CD80                <1>   int  80H			;; Make kernel call
    59                              <1> 
    60                              <1> ;;=======================================================================75
    61                              <1> ;; --== Define Data Section as following Code Section ==--
    62                              <1> ;; -= F I R S T   D A T A =-
    63                              <1> ;;=======================================================================75
    64                              <1>   [SECTION .data] ;; first .dseg
    65 00000000 0000000000000000    <1> SN_CTRL:  DB  0,0,0,0,0,0,0,0  ;; - S/N, or Control Number -
    66                              <1> 
    67 00000008 0A2D70726F6772616D- <1> Msg: db 10,"-program terminated normally-",10,10
    68 00000011 207465726D696E6174- <1>
    69 0000001A 6564206E6F726D616C- <1>
    70 00000023 6C792D0A0A          <1>
    71                              <1> Msg_Len: equ $-Msg
    72                              <1> ;;=======================================================================75
    73                              <1> ;; - =   E O   P R O L O G _ E   = -
    74                              <1> ;;=======================================================================75
    75                                  ;; --== NASM vers. 26-Mar-2010 ==--
    76                                  	;; ***---- Program Body ----***
    77                                  	  [SECTION .text]
    78                                  ;/* File: tst_1.c
    79                                  ;** Last: Sun 21 Aug 2011 10:40:29 PM CDT 
    80                                  ;** Prev: Sat 20 Aug 2011 12:48:59 PM CDT
    81                                  ;** Init: Sat 20 Aug 2011 07:15:48 AM CDT
    82                                  ;** Vers: 0r4
    83                                  ;** Tgts: compile with ccna32
    84                                  ;** Goal: this is a test to check puts()
    85                                  ;** NASM: -@tst_1.mak
    86                                  ;	-f elf
    87                                  ;	-l tst_1.lst
    88                                  ;	-o tst_1.o
    89                                  ;	-Z tst_1_err.txt
    90                                  ;	tst_1.nsm
    91                                  ;** Link: ld --dynamic-linker /lib/ld-linux.so.2 -lc -o tst_1 tst_1.o
    92                                  ;*/
    93                                  ;#define FILE int
    94                                  ;/*	Define the input line			*/
    95                                  ;#define	LINESIZE	255
    96                                  ;#define	LINEMAX		254	/** LINESIZE-1 **/
    97                                  ;#define EOF		-1	/** these are changed to intenal labels _EOF **/
    98                                  ;#define EOL		10
    99                                  ;#define CR		10
   100                                  ;#define FP_STD_OUT	1	/** stdin=0, stdout=1, stderr=2 **/
   101                                  ;FILE *fp_output, *fp_input, *fp_stdout;
   102                                  ;int chr, v1, v2, desc1;
   103                                  ;char *c_fmt, *d_fmt, chr2;
   104                                  ;/** char *pbufr; **/
   105                                  ;int result; /** v.1, does work **/
   106                                  ;char	linebufr[LINESIZE];	/** parsing buffer **/
   107                                  ;int	ln_ndx,			/** index into buffer **/
   108                                  ;	linecnt,
   109                                  ;	k,			/** chr **/
   110                                  ;	eof_flg;		/** set non-zero on final input eof **/
   111                                  ;main()
   112                                  _main:
   113 0000002D 55                      	PUSH EBP
   114 0000002E 81EC00000000            	SUB  ESP, AutoC1
   115 00000034 89E5                    	MOV  EBP, ESP
   116                                  
   117                                  ;{
   118                                  ;/**	int result; ** v.0, doesn't work. **/
   119                                  ;	c_fmt = "%c";
   120 00000036 BB[28000000]            	MOV  EBX, L_1+0
   121 0000003B 891D[9E010000]          	MOV  DWord [_c_fmt], EBX
   122                                  ;	d_fmt = " %d";
   123 00000041 BB[2B000000]            	MOV  EBX, L_1+3
   124 00000046 891D[A2010000]          	MOV  DWord [_d_fmt], EBX
   125                                  ;	chr2 = '^';
   126 0000004C BB5E000000              	MOV  EBX, +94
   127 00000051 881D[A6010000]          	MOV  Byte [_chr2], BL
   128                                  ;	result = 1;
   129 00000057 BB01000000              	MOV  EBX, +1
   130 0000005C 891D[A7010000]          	MOV  DWord [_result], EBX
   131                                  ;/**	pbufr = &linebufr[0]; **/
   132                                  ;	puts("Testing puts.");
   133 00000062 BB[2F000000]            	MOV  EBX, L_1+7
   134 00000067 53                      	PUSH EBX
   135 00000068 E811050000              	CALL _puts
   136 0000006D 81C404000000            	ADD  ESP, +4
   137                                  ;	if ((fp_output = fopen("mytst.txt","w")) == NULL) /* if given, open */
   138 00000073 BB[3D000000]            	MOV  EBX, L_1+21
   139 00000078 53                      	PUSH EBX
   140 00000079 BB[47000000]            	MOV  EBX, L_1+31
   141 0000007E 53                      	PUSH EBX
   142 0000007F E8CE040000              	CALL _fopen
   143 00000084 81C408000000            	ADD  ESP, +8
   144 0000008A 891D[82010000]          	MOV  DWord [_fp_output], EBX
   145 00000090 53                      	PUSH EBX
   146 00000091 BB00000000              	MOV  EBX, _NULL
   147 00000096 5A                      	POP  EDX
   148 00000097 E80C050000              	CALL cceq
   149 0000009C 09DB                    	OR   EBX, EBX
   150 0000009E 7505                    	JNZ  L_2
   151 000000A0 E921000000              	JMP  L_3
   152                                  L_2:
   153                                  ;		{
   154                                  ;		fp_output = NULL;	/* can't open */
   155 000000A5 BB00000000              	MOV  EBX, _NULL
   156 000000AA 891D[82010000]          	MOV  DWord [_fp_output], EBX
   157                                  ;		puts("Open output-file failure!");
   158 000000B0 BB[49000000]            	MOV  EBX, L_1+33
   159 000000B5 53                      	PUSH EBX
   160 000000B6 E8C3040000              	CALL _puts
   161 000000BB 81C404000000            	ADD  ESP, +4
   162                                  ;		}
   163                                  ;	else puts("output-file opened.");
   164 000000C1 E911000000              	JMP  L_4
   165                                  L_3:
   166 000000C6 BB[63000000]            	MOV  EBX, L_1+59
   167 000000CB 53                      	PUSH EBX
   168 000000CC E8AD040000              	CALL _puts
   169 000000D1 81C404000000            	ADD  ESP, +4
   170                                  L_4:
   171                                  ;	if ((fp_input = fopen("tst_1.c","r")) == NULL) /* if given, open */
   172 000000D7 BB[77000000]            	MOV  EBX, L_1+79
   173 000000DC 53                      	PUSH EBX
   174 000000DD BB[7F000000]            	MOV  EBX, L_1+87
   175 000000E2 53                      	PUSH EBX
   176 000000E3 E86A040000              	CALL _fopen
   177 000000E8 81C408000000            	ADD  ESP, +8
   178 000000EE 891D[86010000]          	MOV  DWord [_fp_input], EBX
   179 000000F4 53                      	PUSH EBX
   180 000000F5 BB00000000              	MOV  EBX, _NULL
   181 000000FA 5A                      	POP  EDX
   182 000000FB E8A8040000              	CALL cceq
   183 00000100 09DB                    	OR   EBX, EBX
   184 00000102 7505                    	JNZ  L_5
   185 00000104 E921000000              	JMP  L_6
   186                                  L_5:
   187                                  ;		{
   188                                  ;		fp_input = NULL;	/* can't open */
   189 00000109 BB00000000              	MOV  EBX, _NULL
   190 0000010E 891D[86010000]          	MOV  DWord [_fp_input], EBX
   191                                  ;		puts("Open input-file failure!");
   192 00000114 BB[81000000]            	MOV  EBX, L_1+89
   193 00000119 53                      	PUSH EBX
   194 0000011A E85F040000              	CALL _puts
   195 0000011F 81C404000000            	ADD  ESP, +4
   196                                  ;		}
   197                                  ;	else puts("input-file opened.");
   198 00000125 E911000000              	JMP  L_7
   199                                  L_6:
   200 0000012A BB[9A000000]            	MOV  EBX, L_1+114
   201 0000012F 53                      	PUSH EBX
   202 00000130 E849040000              	CALL _puts
   203 00000135 81C404000000            	ADD  ESP, +4
   204                                  L_7:
   205                                  ;/**  get stdio FILE * value so that we can fputs() to it. **/
   206                                  ;/**  fdopen (int filedes, const char *opentype) **/
   207                                  ;	
   208                                  ;	if ((fp_stdout = fdopen (FP_STD_OUT, "w")) == NULL)
   209 0000013B BB01000000              	MOV  EBX, +1
   210 00000140 53                      	PUSH EBX
   211 00000141 BB[AD000000]            	MOV  EBX, L_1+133
   212 00000146 53                      	PUSH EBX
   213 00000147 E8EE030000              	CALL _fdopen
   214 0000014C 81C408000000            	ADD  ESP, +8
   215 00000152 891D[8A010000]          	MOV  DWord [_fp_stdout], EBX
   216 00000158 53                      	PUSH EBX
   217 00000159 BB00000000              	MOV  EBX, _NULL
   218 0000015E 5A                      	POP  EDX
   219 0000015F E844040000              	CALL cceq
   220 00000164 09DB                    	OR   EBX, EBX
   221 00000166 7505                    	JNZ  L_8
   222 00000168 E911000000              	JMP  L_9
   223                                  L_8:
   224                                  ;		puts ("fdopen() error. ");
   225 0000016D BB[AF000000]            	MOV  EBX, L_1+135
   226 00000172 53                      	PUSH EBX
   227 00000173 E806040000              	CALL _puts
   228 00000178 81C404000000            	ADD  ESP, +4
   229                                  ;	printf(d_fmt,fp_stdout);
   230                                  L_9:
   231 0000017E 8B1D[A2010000]          	MOV  EBX, [DWord _d_fmt]
   232 00000184 53                      	PUSH EBX
   233 00000185 8B1D[8A010000]          	MOV  EBX, [DWord _fp_stdout]
   234 0000018B 53                      	PUSH EBX
   235 0000018C E878030000              	CALL _printf
   236 00000191 81C408000000            	ADD  ESP, +8
   237                                  ;	putchar(10);
   238 00000197 BB0A000000              	MOV  EBX, +10
   239 0000019C 53                      	PUSH EBX
   240 0000019D E83B030000              	CALL _putchar
   241 000001A2 81C404000000            	ADD  ESP, +4
   242                                  ;	if ((desc1 = fileno(fp_stdout)) == -1)
   243 000001A8 8B1D[8A010000]          	MOV  EBX, [DWord _fp_stdout]
   244 000001AE 53                      	PUSH EBX
   245 000001AF E872030000              	CALL _fileno
   246 000001B4 81C404000000            	ADD  ESP, +4
   247 000001BA 891D[9A010000]          	MOV  DWord [_desc1], EBX
   248 000001C0 53                      	PUSH EBX
   249 000001C1 BB01000000              	MOV  EBX, +1
   250 000001C6 F7DB                    	NEG  EBX
   251 000001C8 5A                      	POP  EDX
   252 000001C9 E8DA030000              	CALL cceq
   253 000001CE 09DB                    	OR   EBX, EBX
   254 000001D0 7505                    	JNZ  L_10
   255 000001D2 E911000000              	JMP  L_11
   256                                  L_10:
   257                                  ;		puts ("fileno() error. ");
   258 000001D7 BB[C0000000]            	MOV  EBX, L_1+152
   259 000001DC 53                      	PUSH EBX
   260 000001DD E89C030000              	CALL _puts
   261 000001E2 81C404000000            	ADD  ESP, +4
   262                                  ;	printf(d_fmt, desc1);
   263                                  L_11:
   264 000001E8 8B1D[A2010000]          	MOV  EBX, [DWord _d_fmt]
   265 000001EE 53                      	PUSH EBX
   266 000001EF 8B1D[9A010000]          	MOV  EBX, [DWord _desc1]
   267 000001F5 53                      	PUSH EBX
   268 000001F6 E80E030000              	CALL _printf
   269 000001FB 81C408000000            	ADD  ESP, +8
   270                                  ;	putchar(10);
   271 00000201 BB0A000000              	MOV  EBX, +10
   272 00000206 53                      	PUSH EBX
   273 00000207 E8D1020000              	CALL _putchar
   274 0000020C 81C404000000            	ADD  ESP, +4
   275                                  ;/**	pbufr = "fputs string."; **/
   276                                  ;/***
   277                                  ;	fputs (" fdopen fputs", fp_stdout);
   278                                  ;	putchar(10);
   279                                  ;***/
   280                                  ;	puts("Do file operations here.., and close.");
   281 00000212 BB[D1000000]            	MOV  EBX, L_1+169
   282 00000217 53                      	PUSH EBX
   283 00000218 E861030000              	CALL _puts
   284 0000021D 81C404000000            	ADD  ESP, +4
   285                                  ;/**	while (result == 1) ** works
   286                                  ;		{
   287                                  ;		putchar('.');
   288                                  ;		chr = fgetc(fp_input);** ** works **/
   289                                  ;/**		if (chr == EOF)
   290                                  ;			{
   291                                  ;			result = 0;
   292                                  ;			break;
   293                                  ;			}
   294                                  ;		else fputc(chr,fp_output); ** works **
   295                                  ;		}
   296                                  ;**/
   297                                  ;/**	while ((chr = fgetc(fp_input)) != EOF)  fputc(chr,fp_output); ** works **/
   298                                  ;/**	printf(c_fmt, chr2); ** works **/
   299                                  ;/** 	while ((chr = fgetc(fp_input)) != EOF) putchar(chr); ** works **/
   300                                  ;/**	while ((chr = fgetc(fp_input)) != EOF) printf(c_fmt,chr); ** works **/
   301                                  ;	putchar(10);
   302 00000223 BB0A000000              	MOV  EBX, +10
   303 00000228 53                      	PUSH EBX
   304 00000229 E8AF020000              	CALL _putchar
   305 0000022E 81C404000000            	ADD  ESP, +4
   306                                  ;	processfile();
   307 00000234 E8BB000000              	CALL _processfile
   308                                  ;	putchar(10);
   309 00000239 BB0A000000              	MOV  EBX, +10
   310 0000023E 53                      	PUSH EBX
   311 0000023F E899020000              	CALL _putchar
   312 00000244 81C404000000            	ADD  ESP, +4
   313                                  ;	if ((result = fclose(fp_output)) == 0) puts("Output file closed.");
   314 0000024A 8B1D[82010000]          	MOV  EBX, [DWord _fp_output]
   315 00000250 53                      	PUSH EBX
   316 00000251 E814030000              	CALL _fclose
   317 00000256 81C404000000            	ADD  ESP, +4
   318 0000025C 891D[A7010000]          	MOV  DWord [_result], EBX
   319 00000262 53                      	PUSH EBX
   320 00000263 BB00000000              	MOV  EBX, +0
   321 00000268 5A                      	POP  EDX
   322 00000269 E83A030000              	CALL cceq
   323 0000026E 09DB                    	OR   EBX, EBX
   324 00000270 7505                    	JNZ  L_12
   325 00000272 E916000000              	JMP  L_13
   326                                  L_12:
   327 00000277 BB[F7000000]            	MOV  EBX, L_1+207
   328 0000027C 53                      	PUSH EBX
   329 0000027D E8FC020000              	CALL _puts
   330 00000282 81C404000000            	ADD  ESP, +4
   331                                  ;	else puts("Output file close error.");
   332 00000288 E911000000              	JMP  L_14
   333                                  L_13:
   334 0000028D BB[0B010000]            	MOV  EBX, L_1+227
   335 00000292 53                      	PUSH EBX
   336 00000293 E8E6020000              	CALL _puts
   337 00000298 81C404000000            	ADD  ESP, +4
   338                                  L_14:
   339                                  ;	if ((result = fclose(fp_input)) == 0) puts("Input file closed.");
   340 0000029E 8B1D[86010000]          	MOV  EBX, [DWord _fp_input]
   341 000002A4 53                      	PUSH EBX
   342 000002A5 E8C0020000              	CALL _fclose
   343 000002AA 81C404000000            	ADD  ESP, +4
   344 000002B0 891D[A7010000]          	MOV  DWord [_result], EBX
   345 000002B6 53                      	PUSH EBX
   346 000002B7 BB00000000              	MOV  EBX, +0
   347 000002BC 5A                      	POP  EDX
   348 000002BD E8E6020000              	CALL cceq
   349 000002C2 09DB                    	OR   EBX, EBX
   350 000002C4 7505                    	JNZ  L_15
   351 000002C6 E916000000              	JMP  L_16
   352                                  L_15:
   353 000002CB BB[24010000]            	MOV  EBX, L_1+252
   354 000002D0 53                      	PUSH EBX
   355 000002D1 E8A8020000              	CALL _puts
   356 000002D6 81C404000000            	ADD  ESP, +4
   357                                  ;	else puts("Input file close error.");
   358 000002DC E911000000              	JMP  L_17
   359                                  L_16:
   360 000002E1 BB[37010000]            	MOV  EBX, L_1+271
   361 000002E6 53                      	PUSH EBX
   362 000002E7 E892020000              	CALL _puts
   363 000002EC 81C404000000            	ADD  ESP, +4
   364                                  L_17:
   365                                  ;}
   366 000002F2 5D                      	POP  EBP
   367 000002F3 C3                      	RET
   368                                  
   369                                  AutoC1	EQU 0
   370                                  
   371                                  	  [SECTION .data]
   372 00000028 256300                  L_1	DB "%c",0
   373 0000002B 20256400                	DB " %d",0
   374 0000002F 54657374696E672070-     	DB "Testing puts.",0
   375 00000038 7574732E00         
   376 0000003D 6D797473742E747874-     	DB "mytst.txt",0
   377 00000046 00                 
   378 00000047 7700                    	DB "w",0
   379 00000049 4F70656E206F757470-     	DB "Open output-file failure!",0
   380 00000052 75742D66696C652066-
   381 0000005B 61696C7572652100   
   382 00000063 6F75747075742D6669-     	DB "output-file opened.",0
   383 0000006C 6C65206F70656E6564-
   384 00000075 2E00               
   385 00000077 7473745F312E6300        	DB "tst_1.c",0
   386 0000007F 7200                    	DB "r",0
   387 00000081 4F70656E20696E7075-     	DB "Open input-file failure!",0
   388 0000008A 742D66696C65206661-
   389 00000093 696C7572652100     
   390 0000009A 696E7075742D66696C-     	DB "input-file opened.",0
   391 000000A3 65206F70656E65642E-
   392 000000AC 00                 
   393 000000AD 7700                    	DB "w",0
   394 000000AF 66646F70656E282920-     	DB "fdopen() error. ",0
   395 000000B8 6572726F722E2000   
   396 000000C0 66696C656E6F282920-     	DB "fileno() error. ",0
   397 000000C9 6572726F722E2000   
   398 000000D1 446F2066696C65206F-     	DB "Do file operations here.., and close.",0
   399 000000DA 7065726174696F6E73-
   400 000000E3 20686572652E2E2C20-
   401 000000EC 616E6420636C6F7365-
   402 000000F5 2E00               
   403 000000F7 4F7574707574206669-     	DB "Output file closed.",0
   404 00000100 6C6520636C6F736564-
   405 00000109 2E00               
   406 0000010B 4F7574707574206669-     	DB "Output file close error.",0
   407 00000114 6C6520636C6F736520-
   408 0000011D 6572726F722E00     
   409 00000124 496E7075742066696C-     	DB "Input file closed.",0
   410 0000012D 6520636C6F7365642E-
   411 00000136 00                 
   412 00000137 496E7075742066696C-     	DB "Input file close error.",0
   413 00000140 6520636C6F73652065-
   414 00000149 72726F722E00       
   415                                  
   416                                  	  [SECTION .text]
   417                                  ; /** main input function, chrs accumulate into static linebufr[], **/
   418                                  ; /** also echoes to file commentary tokens, if desired by user. **/
   419                                  ; /** a byte value > 7Fh (sign set) is read as eof in this function **/
   420                                  ; /** On return, linebufr[] holds string of k's, where k is of the set **/
   421                                  ; /** of bytes {1..7Fh} with a null termination, 0. **/
   422                                  ;processfile()
   423                                  _processfile:
   424 000002F4 55                      	PUSH EBP
   425 000002F5 81EC00000000            	SUB  ESP, AutoC18
   426 000002FB 89E5                    	MOV  EBP, ESP
   427                                  
   428                                  ;{
   429                                  ;	ln_ndx = 0;
   430 000002FD BB00000000              	MOV  EBX, +0
   431 00000302 891D[AA020000]          	MOV  DWord [_ln_ndx], EBX
   432                                  ;	eof_flg = 0;
   433 00000308 BB00000000              	MOV  EBX, +0
   434 0000030D 891D[B6020000]          	MOV  DWord [_eof_flg], EBX
   435                                  ;	linecnt = 0;
   436 00000313 BB00000000              	MOV  EBX, +0
   437 00000318 891D[AE020000]          	MOV  DWord [_linecnt], EBX
   438                                  ;	while(1)
   439                                  L_19:
   440 0000031E BB01000000              	MOV  EBX, +1
   441 00000323 09DB                    	OR   EBX, EBX
   442 00000325 7505                    	JNZ  L_20
   443 00000327 E9FC000000              	JMP  L_21
   444                                  L_20:
   445                                  ;		{
   446                                  ;		
   447                                  ;		if (eof_flg) break;
   448 0000032C 8B1D[B6020000]          	MOV  EBX, [DWord _eof_flg]
   449 00000332 09DB                    	OR   EBX, EBX
   450 00000334 7505                    	JNZ  L_22
   451 00000336 E905000000              	JMP  L_23
   452                                  L_22:
   453 0000033B E9E8000000              	JMP  L_21
   454                                  ;		
   455                                  ;		clr_ln();					/** clear line index **/
   456                                  L_23:
   457 00000340 E842010000              	CALL _clr_ln
   458                                  ;		while ((k = fgetc (fp_input)) != EOF) 		/** main fetch fn **/
   459                                  L_24:
   460 00000345 8B1D[86010000]          	MOV  EBX, [DWord _fp_input]
   461 0000034B 53                      	PUSH EBX
   462 0000034C E878010000              	CALL _fgetc
   463 00000351 81C404000000            	ADD  ESP, +4
   464 00000357 891D[B2020000]          	MOV  DWord [_k], EBX
   465 0000035D 53                      	PUSH EBX
   466 0000035E BB01000000              	MOV  EBX, +1
   467 00000363 F7DB                    	NEG  EBX
   468 00000365 5A                      	POP  EDX
   469 00000366 E84C020000              	CALL ccne
   470 0000036B 09DB                    	OR   EBX, EBX
   471 0000036D 7505                    	JNZ  L_25
   472 0000036F E9A4000000              	JMP  L_26
   473                                  L_25:
   474                                  ;			{
   475                                  ;			if (ln_ndx >= 254)			/** linemax **/
   476 00000374 8B1D[AA020000]          	MOV  EBX, [DWord _ln_ndx]
   477 0000037A 53                      	PUSH EBX
   478 0000037B BBFE000000              	MOV  EBX, +254
   479 00000380 5A                      	POP  EDX
   480 00000381 E86D020000              	CALL ccge
   481 00000386 09DB                    	OR   EBX, EBX
   482 00000388 7505                    	JNZ  L_27
   483 0000038A E918000000              	JMP  L_28
   484                                  L_27:
   485                                  ;				{
   486                                  ;				puts ("Error, line length exceeds line buffer size.");
   487 0000038F BB[4F010000]            	MOV  EBX, L_18+0
   488 00000394 53                      	PUSH EBX
   489 00000395 E8E4010000              	CALL _puts
   490 0000039A 81C404000000            	ADD  ESP, +4
   491                                  ;				clr_ln();
   492 000003A0 E8E2000000              	CALL _clr_ln
   493                                  ;				continue;
   494 000003A5 EB9E                    	JMP  L_24
   495                                  ;				}
   496                                  ;			if (k == EOL)
   497                                  L_28:
   498 000003A7 8B1D[B2020000]          	MOV  EBX, [DWord _k]
   499 000003AD 53                      	PUSH EBX
   500 000003AE BB0A000000              	MOV  EBX, +10
   501 000003B3 5A                      	POP  EDX
   502 000003B4 E8EF010000              	CALL cceq
   503 000003B9 09DB                    	OR   EBX, EBX
   504 000003BB 7505                    	JNZ  L_29
   505 000003BD E930000000              	JMP  L_30
   506                                  L_29:
   507                                  ;				{
   508                                  ;		/**		linebufr[ln_ndx++] = k;	** store input in static char array **/
   509                                  ;				linebufr[ln_ndx] = 0;	/** null terminate line to make string **/
   510 000003C2 BB[AB010000]            	MOV  EBX, _linebufr
   511 000003C7 53                      	PUSH EBX
   512 000003C8 8B1D[AA020000]          	MOV  EBX, [DWord _ln_ndx]
   513 000003CE 5A                      	POP  EDX
   514 000003CF 01D3                    	ADD  EBX, EDX
   515 000003D1 53                      	PUSH EBX
   516 000003D2 BB00000000              	MOV  EBX, +0
   517 000003D7 5F                      	POP  EDI
   518 000003D8 881F                    	MOV  Byte [EDI], BL
   519                                  ;		/**		putchar(k); **/	/** test **/
   520                                  ;				linecnt++;
   521 000003DA 8B1D[AE020000]          	MOV  EBX, [DWord _linecnt]
   522 000003E0 43                      	INC  EBX
   523 000003E1 891D[AE020000]          	MOV  DWord [_linecnt], EBX
   524 000003E7 4B                      	DEC  EBX
   525                                  ;				process_ln();
   526 000003E8 E85F000000              	CALL _process_ln
   527                                  ;				clr_ln();
   528 000003ED E895000000              	CALL _clr_ln
   529                                  ;				}
   530                                  ;			linebufr[ln_ndx++] = k;	/** store input char in static char array **/
   531                                  L_30:
   532 000003F2 BB[AB010000]            	MOV  EBX, _linebufr
   533 000003F7 53                      	PUSH EBX
   534 000003F8 8B1D[AA020000]          	MOV  EBX, [DWord _ln_ndx]
   535 000003FE 43                      	INC  EBX
   536 000003FF 891D[AA020000]          	MOV  DWord [_ln_ndx], EBX
   537 00000405 4B                      	DEC  EBX
   538 00000406 5A                      	POP  EDX
   539 00000407 01D3                    	ADD  EBX, EDX
   540 00000409 53                      	PUSH EBX
   541 0000040A 8B1D[B2020000]          	MOV  EBX, [DWord _k]
   542 00000410 5F                      	POP  EDI
   543 00000411 881F                    	MOV  Byte [EDI], BL
   544                                  ;			} /** eo while **/
   545 00000413 E92DFFFFFF              	JMP  L_24
   546                                  L_26:
   547                                  ;		/** EOF **/
   548                                  ;		eof_flg = TRUE;
   549 00000418 BB01000000              	MOV  EBX, _TRUE
   550 0000041D 891D[B6020000]          	MOV  DWord [_eof_flg], EBX
   551                                  ;		
   552                                  ;		} /** eo while **/
   553 00000423 E9F6FEFFFF              	JMP  L_19
   554                                  L_21:
   555                                  ;	putchar(10);
   556 00000428 BB0A000000              	MOV  EBX, +10
   557 0000042D 53                      	PUSH EBX
   558 0000042E E8AA000000              	CALL _putchar
   559 00000433 81C404000000            	ADD  ESP, +4
   560                                  ;	puts("-eof-");
   561 00000439 BB[7C010000]            	MOV  EBX, L_18+45
   562 0000043E 53                      	PUSH EBX
   563 0000043F E83A010000              	CALL _puts
   564 00000444 81C404000000            	ADD  ESP, +4
   565                                  ;}
   566 0000044A 5D                      	POP  EBP
   567 0000044B C3                      	RET
   568                                  
   569                                  AutoC18	EQU 0
   570                                  
   571                                  	  [SECTION .data]
   572 0000014F 4572726F722C206C69-     L_18	DB "Error, line length exceeds line buffer size.",0
   573 00000158 6E65206C656E677468-
   574 00000161 206578636565647320-
   575 0000016A 6C696E652062756666-
   576 00000173 65722073697A652E00 
   577 0000017C 2D656F662D00            	DB "-eof-",0
   578                                  
   579                                  	  [SECTION .text]
   580                                  ;/*
   581                                  ;** process line in the buffer as a string.
   582                                  ;*/
   583                                  ;process_ln()
   584                                  _process_ln:
   585 0000044C 55                      	PUSH EBP
   586 0000044D 81EC00000000            	SUB  ESP, AutoC31
   587 00000453 89E5                    	MOV  EBP, ESP
   588                                  
   589                                  ;{
   590                                  ;/**	fputs (linebufr, stdout); ** need to find stdout's ptr value **/
   591                                  ;	fputs (linebufr, fp_stdout);
   592 00000455 BB[AB010000]            	MOV  EBX, _linebufr
   593 0000045A 53                      	PUSH EBX
   594 0000045B 8B1D[8A010000]          	MOV  EBX, [DWord _fp_stdout]
   595 00000461 53                      	PUSH EBX
   596 00000462 E829010000              	CALL _fputs
   597 00000467 81C408000000            	ADD  ESP, +8
   598                                  ;	fputs (linebufr, fp_output);
   599 0000046D BB[AB010000]            	MOV  EBX, _linebufr
   600 00000472 53                      	PUSH EBX
   601 00000473 8B1D[82010000]          	MOV  EBX, [DWord _fp_output]
   602 00000479 53                      	PUSH EBX
   603 0000047A E811010000              	CALL _fputs
   604 0000047F 81C408000000            	ADD  ESP, +8
   605                                  ;/**	puts (linebufr);	**/		/** FILE output, fp_output **/
   606                                  ;/**	fputc (EOL, fp_output);  */
   607                                  ;}
   608 00000485 5D                      	POP  EBP
   609 00000486 C3                      	RET
   610                                  
   611                                  AutoC31	EQU 0
   612                                  ;/*
   613                                  ;** reindex & null terminate input line.
   614                                  ;*/
   615                                  ;clr_ln()
   616                                  _clr_ln:
   617 00000487 55                      	PUSH EBP
   618 00000488 81EC00000000            	SUB  ESP, AutoC32
   619 0000048E 89E5                    	MOV  EBP, ESP
   620                                  
   621                                  ;{
   622                                  ;	ln_ndx = 0;
   623 00000490 BB00000000              	MOV  EBX, +0
   624 00000495 891D[AA020000]          	MOV  DWord [_ln_ndx], EBX
   625                                  ;	linebufr[ln_ndx] = 0;
   626 0000049B BB[AB010000]            	MOV  EBX, _linebufr
   627 000004A0 53                      	PUSH EBX
   628 000004A1 8B1D[AA020000]          	MOV  EBX, [DWord _ln_ndx]
   629 000004A7 5A                      	POP  EDX
   630 000004A8 01D3                    	ADD  EBX, EDX
   631 000004AA 53                      	PUSH EBX
   632 000004AB BB00000000              	MOV  EBX, +0
   633 000004B0 5F                      	POP  EDI
   634 000004B1 881F                    	MOV  Byte [EDI], BL
   635                                  ;}
   636 000004B3 5D                      	POP  EBP
   637 000004B4 C3                      	RET
   638                                  
   639                                  AutoC32	EQU 0
   640                                  ;/*
   641                                  ;** eo tst_1.c
   642                                  ;*/
   643                                  
   644                                  	  [SECTION .data]
   645 00000182 00000000                _fp_output:	TIMES +1	DD 0
   646 00000186 00000000                _fp_input:	TIMES +1	DD 0
   647 0000018A 00000000                _fp_stdout:	TIMES +1	DD 0
   648 0000018E 00000000                _chr:	TIMES +1	DD 0
   649 00000192 00000000                _v1:	TIMES +1	DD 0
   650 00000196 00000000                _v2:	TIMES +1	DD 0
   651 0000019A 00000000                _desc1:	TIMES +1	DD 0
   652 0000019E 00000000                _c_fmt:	TIMES +1	DD 0
   653 000001A2 00000000                _d_fmt:	TIMES +1	DD 0
   654 000001A6 00                      _chr2:	TIMES +1	DB 0
   655 000001A7 00000000                _result:	TIMES +1	DD 0
   656 000001AB 00                _linebufr:	TIMES +255	DB 0
   657 000002AA 00000000                _ln_ndx:	TIMES +1	DD 0
   658 000002AE 00000000                _linecnt:	TIMES +1	DD 0
   659 000002B2 00000000                _k:	TIMES +1	DD 0
   660 000002B6 00000000                _eof_flg:	TIMES +1	DD 0
   661                                  
   662                                  	  [SECTION .text]
   663                                  
   664                                  	%INCLUDE 'EPILOG.NSM' 
   665                              <1> ;;=======================================================================75
   666                              <1> ;; File: EPILOG.NSM  By: s_dubrovich@yahoo.com
   667                              <1> ;; Last: Tue 26 Jul 2011 09:20:22 PM CDT
   668                              <1> ;; Prev: 06-May-11 02:14:06 PM,06-May-11 11:04:48 PM,21-May-11 11:16:52 PM
   669                              <1> ;; Init: 10-Jan-10 10:11:21 PM
   670                              <1> ;; Vers: 4r1
   671                              <1> ;; Note: Epilog. Pair to PROLOG.NSM.  Adjust stack size to your need.
   672                              <1> ;; 
   673                              <1> ;;=======================================================================75
   674                              <1> 
   675                              <1> %INCLUDE 'IO_CLIB.NSM'
   676                              <2> ;;-----------------------------------------------------------------------75
   677                              <2> ;; File: IO_LIB.NSM  By: s_dubrovich@yahoo.com
   678                              <2> ;; ?(c): COPYLEFT
   679                              <2> ;; Last: Sat 13 Aug 2011 05:55:04 PM CDT
   680                              <2> ;; Prev: Sat 13 Aug 2011 05:55:04 PM CDT
   681                              <2> ;; Init: Sat 13 Aug 2011 05:55:04 PM CDT
   682                              <2> ;; Vers: v.0r0
   683                              <2> ;;-----------------------------------------------------------------------75
   684                              <2> ;; Sat 13 Aug 2011 05:55:04 PM CDT - initial.
   685                              <2> ;;-----------------------------------------------------------------------75
   686                              <2> ;; !!!!: requires linking to dynamic library..
   687                              <2> ;; Linking when an external C library is to be used to link externals:
   688                              <2> ;; ld --dynamic-linker /lib/ld-linux.so.2 -lc -o program program.o
   689                              <2> ;;
   690                              <2> ;; /** getc(){;} gets(){;} putc(){;}  **/
   691                              <2> ;; /** putchar(){;} fopen(){;} fclose(){;}  **/
   692                              <2> ;;-----------------------------------------------------------------------75
   693                              <2> ;; -snippets from libc.pdf-
   694                              <2> ;; 11.1.1 Streams and File Descriptors
   695                              <2> ;;
   696                              <2> ;; When you want to do input or output to a file, you have a choice of two
   697                              <2> ;; basic mechanisms for representing the connection between your program
   698                              <2> ;; and the file: file descriptors and streams.  File descriptors are
   699                              <2> ;; represented as objects of type int, (open(), close()), while streams
   700                              <2> ;; are represented as FILE * objects, (fopen(), fclose()).  File
   701                              <2> ;; descriptors provide a primitive, low-level interface to input and output
   702                              <2> ;; operations.
   703                              <2> ;;
   704                              <2> ;; Since streams are implemented in terms of file descriptors, you can
   705                              <2> ;; extract the file descriptor from a stream and perform low-level
   706                              <2> ;; operations directly on the file descriptor.  You can also initially open
   707                              <2> ;; a connection as a file descriptor and then make a stream associated
   708                              <2> ;; with that file descriptor.
   709                              <2> ;;
   710                              <2> ;; If you are concerned about portability of your programs to systems other
   711                              <2> ;; than GNU, you should also be aware that file descriptors are not as
   712                              <2> ;; portable as streams.  You can expect any system running ISO C to support
   713                              <2> ;; streams, but non-GNU systems may not support file descriptors at all, or
   714                              <2> ;; may only implement a subset of the GNU functions that operate on file
   715                              <2> ;; descriptors. Most of the file descriptor functions in the GNU library
   716                              <2> ;; are included in the POSIX.1 standard, however.
   717                              <2> ;;-----------------------------------------------------------------------75
   718                              <2> ;; NOTE: the FILE * stream functions return NULL on open error.
   719                              <2> ;;  The int file descriptor functions return -1 on open error.
   720                              <2> ;;-----------------------------------------------------------------------75
   721                              <2> ;; It is an error to fopen a file for reading if it doesn't exist.
   722                              <2> ;; A file is created by fopen'ing one for writing.  If the file already
   723                              <2> ;; exists, it is destroyed by the fopen.  "The GNU C library defines one
   724                              <2> ;; additional character for use in opentype: the character ‘x’ insists on
   725                              <2> ;; creating a new file—if a file filename already exists, fopen fails
   726                              <2> ;; rather than opening it. (non-destructive open.)
   727                              <2> ;;-----------------------------------------------------------------------75
   728                              <2> ;; There are also symbolic constants defined in ‘unistd.h’ for the file
   729                              <2> ;; descriptors belonging to the standard streams stdin, stdout, and stderr;
   730                              <2> ;; see Section 12.2 [Standard Streams], page 226.
   731                              <2> ;;  STDIN_FILENO
   732                              <2> ;; This macro has value 0, which is the file descriptor for standard input.
   733                              <2> ;;  STDOUT_FILENO
   734                              <2> ;; This macro has value 1, which is the file descriptor for standard output.
   735                              <2> ;;  STDERR_FILENO
   736                              <2> ;; This macro has value 2, which is the file descriptor for standard error
   737                              <2> ;; output.
   738                              <2> ;;-----------------------------------------------------------------------75
   739                              <2> 
   740                              <2> _NULL EQU 0
   741                              <2> _TRUE EQU 1
   742                              <2> 
   743                              <2> ;; -= int getc (FILE *stream) `F_INPUT =-
   744                              <2> 
   745                              <2> extern getc
   746                              <2> 
   747                              <2> _getc:
   748 000004B5 89E5                <2> 	mov	ebp, esp
   749 000004B7 8B4504              <2> 	mov	eax, [ebp + 4]
   750 000004BA 50                  <2> 	push	eax
   751 000004BB E8(00000000)        <2> 	call	getc
   752 000004C0 89C3                <2> 	mov	ebx, eax
   753 000004C2 81C404000000        <2> 	add	esp, 4
   754 000004C8 C3                  <2> 	RET
   755                              <2> 
   756                              <2> ;; -= int fgetc (FILE *stream) =-
   757                              <2> ;; This function reads the next character as an unsigned char from the
   758                              <2> ;; stream 'stream' and returns its value, converted to an int. If an
   759                              <2> ;; end-of-file condition or read error occurs, EOF is returned instead.
   760                              <2> 
   761                              <2> extern fgetc
   762                              <2> 
   763                              <2> _fgetc:
   764 000004C9 89E5                <2> 	mov	ebp, esp
   765 000004CB 8B4504              <2> 	mov	eax, [ebp + 4]
   766 000004CE 50                  <2> 	push	eax
   767 000004CF E8(00000000)        <2> 	call	fgetc
   768 000004D4 89C3                <2> 	mov	ebx, eax
   769 000004D6 81C404000000        <2> 	add	esp, 4
   770 000004DC C3                  <2> 	RET
   771                              <2> 
   772                              <2> ;; -= char * gets (char *s) `STDIN =-
   773                              <2> ;; -= int putchar (int c) .eqiv. putc(c,stdout). `STDOUT =-
   774                              <2> ;; -= int putc (int c, FILE *stream) `F_OUTPUT =-
   775                              <2> 
   776                              <2> extern putchar
   777                              <2> 
   778                              <2> _putchar:
   779 000004DD 89E5                <2> 	mov	ebp, esp
   780 000004DF 8B4504              <2> 	mov	eax, [ebp + 4]
   781 000004E2 50                  <2> 	push	eax
   782 000004E3 E8(00000000)        <2> 	call	putchar
   783 000004E8 89C3                <2> 	mov	ebx, eax
   784 000004EA 81C404000000        <2> 	add	esp, 4
   785 000004F0 C3                  <2> 	RET
   786                              <2> 
   787                              <2> ;; -= int fputc (int c, FILE *stream) `F_OUTPUT =-
   788                              <2> ;; The fputc function converts the character c to type unsigned char, and
   789                              <2> ;;  writes it to the stream stream. EOF is returned if a write error occurs;
   790                              <2> ;;  otherwise the character c is returned.
   791                              <2> 
   792                              <2> extern fputc			;; resides in c library:
   793                              <2> 
   794                              <2> _fputc:
   795 000004F1 89E5                <2> 	mov	ebp, esp	;; TOS 0[RET], 4[fp_output], 8[chr]
   796 000004F3 8B4508              <2> 	mov	eax, [ebp + 8]
   797 000004F6 8B5D04              <2> 	mov	ebx, [ebp + 4]	;; changes argument order & places below return addr
   798 000004F9 53                  <2> 	push	ebx
   799 000004FA 50                  <2> 	push	eax		;; TOS 0[chr], 4[fp_output]
   800 000004FB E8(00000000)        <2> 	call	fputc		;; returns FILE * in EAX
   801 00000500 89C3                <2> 	mov	ebx, eax
   802 00000502 81C408000000        <2> 	add	esp, 8
   803 00000508 C3                  <2> 	RET
   804                              <2> 
   805                              <2> ;; -= printf(fmt_str,val1);
   806                              <2> 
   807                              <2> extern printf
   808                              <2> 
   809                              <2> _printf:
   810 00000509 89E5                <2> 	mov	ebp, esp	;; then [ebp + 0] has ret address, and..
   811 0000050B 8B5508              <2> 	mov	edx, [ebp + 8]	;; format
   812 0000050E 8B4504              <2> 	mov	eax, [ebp + 4]	;; chr
   813 00000511 25FF000000          <2> 	and	eax, 0FFh
   814 00000516 50                  <2> 	push	eax
   815 00000517 52                  <2> 	push	edx
   816 00000518 E8(00000000)        <2> 	call	printf
   817 0000051D 89C3                <2> 	mov	ebx, eax
   818 0000051F 81C408000000        <2> 	add	esp, 8
   819 00000525 C3                  <2> 	RET
   820                              <2> 
   821                              <2> ;;-----------------------------------------------------------------------75
   822                              <2> ;; -= int fileno (FILE *stream) =-
   823                              <2> ;; This function returns the file descriptor associated with the stream
   824                              <2> ;; stream. If an error is detected (for example, if the stream is not
   825                              <2> ;; valid) or if stream does not do I/O to a file, fileno returns −1
   826                              <2> 
   827                              <2> extern fileno
   828                              <2> 
   829                              <2> _fileno:
   830 00000526 89E5                <2> 	mov	ebp, esp
   831 00000528 8B4504              <2> 	mov	eax, [ebp + 4]
   832 0000052B 50                  <2> 	push	eax
   833 0000052C E8(00000000)        <2> 	call	fileno
   834 00000531 89C3                <2> 	mov	ebx, eax
   835 00000533 81C404000000        <2> 	add	esp, 4
   836 00000539 C3                  <2> 	RET
   837                              <2> 
   838                              <2> ;; -= FILE * fdopen (int filedes, const char *opentype) =-
   839                              <2> ;; filedes is a number, 1 for stdout, do this to get its FILE *.
   840                              <2> 
   841                              <2> extern fdopen
   842                              <2> 
   843                              <2> _fdopen:
   844 0000053A 89E5                <2> 	mov	ebp, esp	;; TOS 0[RET], 4[otyp], 8[filedes]
   845 0000053C 8B4508              <2> 	mov	eax, [ebp + 8]
   846 0000053F 8B5D04              <2> 	mov	ebx, [ebp + 4]
   847 00000542 53                  <2> 	push	ebx
   848 00000543 50                  <2> 	push	eax
   849 00000544 E8(00000000)        <2> 	call	fdopen		;; returns FILE * in EAX
   850 00000549 89C3                <2> 	mov	ebx, eax
   851 0000054B 81C408000000        <2> 	add	esp, 8
   852 00000551 C3                  <2> 	RET
   853                              <2> 
   854                              <2> ;; -= FILE * fopen (const char *filename, const char *opentype) =-
   855                              <2> 
   856                              <2> extern fopen			;; resides in c library:
   857                              <2> 
   858                              <2> _fopen:
   859 00000552 89E5                <2> 	mov	ebp, esp	;; TOS 0[RET], 4[otyp], 8[fname]
   860 00000554 8B4508              <2> 	mov	eax, [ebp + 8]
   861 00000557 8B5D04              <2> 	mov	ebx, [ebp + 4]
   862 0000055A 53                  <2> 	push	ebx
   863 0000055B 50                  <2> 	push	eax
   864 0000055C E8(00000000)        <2> 	call	fopen		;; returns FILE * in EAX
   865 00000561 89C3                <2> 	mov	ebx, eax
   866 00000563 81C408000000        <2> 	add	esp, 8
   867 00000569 C3                  <2> 	RET
   868                              <2> 
   869                              <2> ;; -= int fclose (FILE *stream) =-
   870                              <2> ;; returns 0 on successful close, else EOF
   871                              <2> 
   872                              <2> extern fclose			;; resides in c library:
   873                              <2> 
   874                              <2> _fclose:
   875 0000056A 89E5                <2> 	mov	ebp, esp
   876 0000056C 8B4504              <2> 	mov	eax, [ebp + 4]
   877 0000056F 50                  <2> 	push	eax
   878 00000570 E8(00000000)        <2> 	call	fclose
   879 00000575 89C3                <2> 	mov	ebx, eax
   880 00000577 81C404000000        <2> 	add	esp, 4
   881 0000057D C3                  <2> 	RET
   882                              <2> 
   883                              <2> ;; -= int puts (const char *c) `STDOUT =-
   884                              <2> ;; copies null-terminated string to stdout, less null, adds \n.
   885                              <2> ;; return: success`non-negative, fail`EOF.
   886                              <2> 
   887                              <2> extern puts			;; resides in c library: int puts (const char *s)
   888                              <2> 
   889                              <2> _puts:				;; ptr in (Primary BX) is passed on the stack.
   890 0000057E 89E5                <2> 	mov	ebp, esp	;; TOS 0[ret], 4[str_ptr]
   891 00000580 8B4504              <2> 	mov	eax, [ebp + 4]	;; retrieve ptr parameter
   892 00000583 50                  <2> 	push	eax		;; ptr to string parameter.
   893 00000584 E8(00000000)        <2> 	call	puts		;; libc function, puts function corrupts ecx
   894 00000589 81C404000000        <2> 	add	esp, 4
   895 0000058F C3                  <2> 	RET
   896                              <2> 
   897                              <2> ;; -= int fputs (const char *s, FILE *stream) =-
   898                              <2> ;; The function fputs writes the string s to the stream stream. The terminating null
   899                              <2> ;; character is not written. This function does not add a newline character, either. It
   900                              <2> ;; outputs only the characters in the string.  This function returns EOF if a write
   901                              <2> ;; error occurs, and otherwise a non-negative value.
   902                              <2> 
   903                              <2> 
   904                              <2> extern fputs
   905                              <2> 
   906                              <2> _fputs:
   907 00000590 89E5                <2> 	mov	ebp, esp	;; TOS 0[RET], 4[str_ptr], 8[strm_ptr]
   908 00000592 8B4508              <2> 	mov	eax, [ebp + 8]
   909 00000595 8B5D04              <2> 	mov	ebx, [ebp + 4]
   910 00000598 53                  <2> 	push	ebx
   911 00000599 50                  <2> 	push	eax
   912 0000059A E8(00000000)        <2> 	call	fputs		;; EAX = EOF if write error.
   913 0000059F 89C3                <2> 	mov	ebx, eax
   914 000005A1 81C408000000        <2> 	add	esp, 8
   915 000005A7 C3                  <2> 	RET
   916                              <2> 
   917                              <2> ;;-----------------------------------------------------------------------75
   918                              <2> ;; File: cond_ops.nsm
   919                              <2> ;; Conditional Operators compare the Secondary Register against the
   920                              <2> ;; Primary Register and put a value of 1 in the Primary Register if the
   921                              <2> ;; condition is true, otherwise they put a value of 0 in the Primary
   922                              <2> ;; Register indicating a condition that is false.
   923                              <2> ;;
   924                              <2> ;; -testing-
   925                              <2> 
   926                              <2> cceq:				;; test for equal
   927 000005A8 39DA                <2> 	cmp	edx, ebx	;; sets flags
   928 000005AA BB01000000          <2> 	mov	ebx, 1		;; assume true
   929 000005AF 7405                <2> 	jz	.next
   930 000005B1 BB00000000          <2> 	mov	ebx, 0		;; is false
   931                              <2> .next:
   932 000005B6 C3                  <2> 	RET
   933                              <2> 
   934                              <2> ccne:				;; test for not equal
   935 000005B7 39DA                <2> 	cmp	edx, ebx	;; sets flags
   936 000005B9 BB01000000          <2> 	mov	ebx, 1		;; assume true
   937 000005BE 7505                <2> 	jnz	.next
   938 000005C0 BB00000000          <2> 	mov	ebx, 0		;; is false
   939                              <2> .next:
   940 000005C5 C3                  <2> 	RET
   941                              <2> 
   942                              <2> cclt:				;; test for less than (signed)
   943 000005C6 39DA                <2> 	cmp	edx, ebx	;; sets flags
   944 000005C8 BB01000000          <2> 	mov	ebx, 1		;; assume true
   945 000005CD 7C05                <2> 	jl	.next
   946 000005CF BB00000000          <2> 	mov	ebx, 0		;; is false
   947                              <2> .next:
   948 000005D4 C3                  <2> 	RET
   949                              <2> 
   950                              <2> ccle:				;; test for less than or equal to (signed)
   951 000005D5 39DA                <2> 	cmp	edx, ebx	;; sets flags
   952 000005D7 BB01000000          <2> 	mov	ebx, 1		;; assume true
   953 000005DC 7E05                <2> 	jle	.next
   954 000005DE BB00000000          <2> 	mov	ebx, 0		;; is false
   955                              <2> .next:
   956 000005E3 C3                  <2> 	RET
   957                              <2> 
   958                              <2> ccgt:				;; test for greater than (signed)
   959 000005E4 39DA                <2> 	cmp	edx, ebx	;; sets flags
   960 000005E6 BB01000000          <2> 	mov	ebx, 1		;; assume true
   961 000005EB 7F05                <2> 	jg	.next
   962 000005ED BB00000000          <2> 	mov	ebx, 0		;; is false
   963                              <2> .next:
   964 000005F2 C3                  <2> 	RET
   965                              <2> 
   966                              <2> ccge:				;; test for greater than or equal to (signed)
   967 000005F3 39DA                <2> 	cmp	edx, ebx	;; sets flags
   968 000005F5 BB01000000          <2> 	mov	ebx, 1		;; assume true
   969 000005FA 7D05                <2> 	jge	.next
   970 000005FC BB00000000          <2> 	mov	ebx, 0		;; is false
   971                              <2> .next:
   972 00000601 C3                  <2> 	RET
   973                              <2> 
   974                              <2> ccult:				;; test for less than (unsigned)
   975 00000602 39DA                <2> 	cmp	edx, ebx	;; sets flags
   976 00000604 BB01000000          <2> 	mov	ebx, 1		;; assume true
   977 00000609 7205                <2> 	jb	.next
   978 0000060B BB00000000          <2> 	mov	ebx, 0		;; is false
   979                              <2> .next:
   980 00000610 C3                  <2> 	RET
   981                              <2> 
   982                              <2> ccule:				;; test for less than or equal to (unsigned)
   983 00000611 39DA                <2> 	cmp	edx, ebx	;; sets flags
   984 00000613 BB01000000          <2> 	mov	ebx, 1		;; assume true
   985 00000618 7605                <2> 	jbe	.next
   986 0000061A BB00000000          <2> 	mov	ebx, 0		;; is false
   987                              <2> .next:
   988 0000061F C3                  <2> 	RET
   989                              <2> 
   990                              <2> ccugt:				;; test for greater than (unsigned)
   991 00000620 39DA                <2> 	cmp	edx, ebx	;; sets flags
   992 00000622 BB01000000          <2> 	mov	ebx, 1		;; assume true
   993 00000627 7705                <2> 	ja	.next
   994 00000629 BB00000000          <2> 	mov	ebx, 0		;; is false
   995                              <2> .next:
   996 0000062E C3                  <2> 	RET
   997                              <2> 
   998                              <2> ccuge:				;; test for greater than or equal to (unsigned)
   999 0000062F 39DA                <2> 	cmp	edx, ebx	;; sets flags
  1000 00000631 BB01000000          <2> 	mov	ebx, 1		;; assume true
  1001 00000636 7305                <2> 	jae	.next
  1002 00000638 BB00000000          <2> 	mov	ebx, 0		;; is false
  1003                              <2> .next:
  1004 0000063D C3                  <2> 	RET
  1005                              <2> 
  1006                              <2> ;; -= eo cond_ops.nsm =-
  1007                              <2> 
  1008                              <2> ;; - eo_IO_LIB.NSM -
  1009                              <2> 
  1010                              <1> ;;=======================================================================75
  1011                              <1> ;; -== S T A C K ==-
  1012                              <1> ;;=======================================================================75
  1013                              <1> 
  1014                              <1>   [SECTION .data]	;; assert as in data.
  1015 000002BA 90            <1> ALIGN 16
  1016                              <1> stackbase:
  1017 000002C0 CCCC          <1>   TIMES 1000h dw 0CCCCh	;; was 800h
  1018                              <1> stacktop:
  1019                              <1>  ;- Len_ss EQU $-$$
  1020                              <1> 
  1021                              <1> ;;-----------------------------------------------------------------------75
  1022                              <1> ;; S E C T I O N S   W R A P - U P
  1023                              <1> ;;-----------------------------------------------------------------------75
  1024                              <1> ;;=======================================================================75
  1025                              <1> ;; -= L A S T   C O D E =-
  1026                              <1> ;;=======================================================================75
  1027                              <1>   [SECTION .text]
  1028                              <1> ;; -= mark end of last .cseg with.. =-
  1029 0000063E 00            <1>  align 16, db 0
  1030                              <1>  Len_cs EQU ($-$$)
  1031                              <1> 
  1032                              <1> ;;=======================================================================75
  1033                              <1> ;; -= L A S T   D A T A =-
  1034                              <1> ;;=======================================================================75
  1035                              <1> ;; -= mark the end of the last .dseg with.. =-
  1036                              <1>   [SECTION .data]
  1037                              <1>  align 16, db 0
  1038                              <1>  Len_ds EQU ($-$$)
  1039                              <1> ;;=======================================================================75
  1040                              <1> ;; - =   E O   E P I L O G _ E   = -
  1041                              <1> ;;=======================================================================75
  1042                              <1> 
  1043                                  ; --- End of Compilation ---