     1                                  ; ****************************************************************************
     2                                  ; cat386.s (Retro Unix 386 v1.2) - /bin/cat - concatenate files
     3                                  ; ----------------------------------------------------------------------------
     4                                  ;
     5                                  ; RETRO UNIX 386 (Retro Unix == Turkish Rational Unix)
     6                                  ; Operating System Project (v0.2) by ERDOGAN TAN (Beginning: 24/12/2013)
     7                                  ;
     8                                  ; Retro UNIX 8086 v1 - '/bin/cat' file
     9                                  ;
    10                                  ; Derived from 'Retro UNIX 8086 v1' source code by Erdogan Tan
    11                                  ; (v0.1 - Beginning: 11/07/2012)
    12                                  ;
    13                                  ; [ Last Modification: 17/06/2022 ] -cat3.s-
    14                                  ;
    15                                  ; Derived from UNIX Operating System (v1.0 for PDP-11) 
    16                                  ; (Original) Source Code by Ken Thompson (Bell Laboratories, 1971-1972)
    17                                  ; ****************************************************************************
    18                                  ; ((nasm cat3.s -l cat3.txt -o cat3 -Z error.txt))
    19                                  ; cat386.s - cat3.s (15/06/2022, Retro UNIX 386 v1.2)
    20                                  ; cat386.s - cat2.s (14/06/2022, Retro UNIX 386 v1 & v1.1)
    21                                  ; cat386.s - cat1.s (05/03/2022, Retro UNIX 386 v1 & v1.1 & v1.2)
    22                                  ; cat386.s - cat0.s (17/10/2015 - 28/12/2015, Retro UNIX 386 v1, NASM 2.11)
    23                                  ; CAT2.ASM (02/12/2013 - 16/07/2015, Retro UNIX 8086 v1, MASM 6.11) 
    24                                  
    25                                  ; 17/10/2015
    26                                  
    27                                  ; UNIX v1 system calls
    28                                  _rele 	equ 0
    29                                  _exit 	equ 1
    30                                  _fork 	equ 2
    31                                  _read 	equ 3
    32                                  _write	equ 4
    33                                  _open	equ 5
    34                                  _close 	equ 6
    35                                  _wait 	equ 7
    36                                  _creat 	equ 8
    37                                  _link 	equ 9
    38                                  _unlink	equ 10
    39                                  _exec	equ 11
    40                                  _chdir	equ 12
    41                                  _time 	equ 13
    42                                  _mkdir 	equ 14
    43                                  _chmod	equ 15
    44                                  _chown	equ 16
    45                                  _break	equ 17
    46                                  _stat	equ 18
    47                                  _seek	equ 19
    48                                  _tell 	equ 20
    49                                  _mount	equ 21
    50                                  _umount	equ 22
    51                                  _setuid	equ 23
    52                                  _getuid	equ 24
    53                                  _stime	equ 25
    54                                  _quit	equ 26	
    55                                  _intr	equ 27
    56                                  _fstat	equ 28
    57                                  _emt 	equ 29
    58                                  _mdate 	equ 30
    59                                  _stty 	equ 31
    60                                  _gtty	equ 32
    61                                  _ilgins	equ 33
    62                                  _sleep	equ 34 ; Retro UNIX 8086 v1 feature only !
    63                                  _msg    equ 35 ; Retro UNIX 386 v1 feature only !
    64                                  _geterr	equ 36 ; Retro UNIX 386 v1 feature only !
    65                                  ; 12/01/2022 - Retro UNIX 386 v1.2
    66                                  ; Retro UNIX 386 v2 system calls
    67                                  _setgid	equ 37
    68                                  _getgid	equ 38
    69                                  _sysver	equ 39 ; (get) Retro Unix 386 version
    70                                  
    71                                  %macro sys 1-4
    72                                      ; 03/09/2015	
    73                                      ; 13/04/2015
    74                                      ; Retro UNIX 386 v1 system call.		
    75                                      %if %0 >= 2   
    76                                          mov ebx, %2
    77                                          %if %0 >= 3    
    78                                              mov ecx, %3
    79                                              %if %0 = 4
    80                                                 mov edx, %4   
    81                                              %endif
    82                                          %endif
    83                                      %endif
    84                                      mov eax, %1
    85                                      int 30h	   
    86                                  %endmacro
    87                                  
    88                                  ; 15/06/2022 - Retro UNIX 386 v1.2
    89                                  struc stat
    90                                     ; Retro UNIX v1.2 'sysstat' output !
    91                                     ; (66 bytes)
    92 00000000 ????                       .inode:  resw 1	
    93 00000002 ????                       .mode:   resw 1
    94 00000004 ????                       .nlinks: resw 1 
    95 00000006 ????                       .uid:    resw 1
    96 00000008 ??                         .gid:    resb 1
    97 00000009 ??                         .size_h: resb 1
    98 0000000A ????????                   .size:   resd 1
    99 0000000E <res 28h>                  .dskptr: resd 10
   100 00000036 ????????                   .atime:  resd 1
   101 0000003A ????????                   .mtime:  resd 1
   102 0000003E ????????                   .ctime:  resd 1
   103                                     .strucsize:
   104                                  endstruc
   105                                  
   106                                  ; Retro UNIX 386 v1 system call format:
   107                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
   108                                  
   109                                  [BITS 32] ; We need 32-bit intructions for protected mode
   110                                  
   111                                  [ORG 0] 
   112                                  
   113                                  START_CODE:
   114                                  	;; / cat -- concatenate files
   115                                  
   116                                  	sys	_write, 1, nl, 2
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1>  %if %0 >= 2
    76 00000000 BB01000000          <1>  mov ebx, %2
    77                              <1>  %if %0 >= 3
    78 00000005 B9[63010000]        <1>  mov ecx, %3
    79                              <1>  %if %0 = 4
    80 0000000A BA02000000          <1>  mov edx, %4
    81                              <1>  %endif
    82                              <1>  %endif
    83                              <1>  %endif
    84 0000000F B804000000          <1>  mov eax, %1
    85 00000014 CD30                <1>  int 30h
   117                                  
   118 00000016 5D                      	pop	ebp
   119 00000017 5A                      	pop	edx
   120                                  	; esi = 0 ; ('sysexec' sets regs to zero)
   121                                  	; 05/03/2022
   122                                  	;mov	esi, fin 
   123                                  	;mov    edi, obuf
   124                                  	;EAX = 2 (written byte count)
   125 00000018 30C0                    	xor	al, al ; 0
   126 0000001A B9[70010000]                    mov	ecx, iobuf ; 17/06/2022
   127 0000001F 4D                      	dec     ebp
   128 00000020 744D                    	jz	short cat_3	
   129                                  		;;mov	(sp)+,r5
   130                                  		;;tst	(sp)+
   131                                  		;;mov	$obuf,r2
   132                                  		;;cmp	r5,$1
   133                                  		;;beq	3f
   134                                  cat_0:	
   135 00000022 5B                      	pop	ebx
   136 00000023 803B2D                  	cmp	byte [ebx], '-'
   137 00000026 7447                    	je	short cat_3 ; 16/06/2022
   138                                  		;;dec	r5
   139                                  		;;ble	done
   140                                  		;;mov	(sp)+,r0
   141                                  		;;cmpb	(r0),$'-
   142                                  		;;bne	2f
   143                                  		;;clr	fin
   144                                  		;;br	3f
   145                                  cat_1:
   146                                  	;;2:
   147                                  	; ebx = file name offset
   148 00000028 31C9                    	xor 	ecx, ecx ; 0
   149                                  	sys 	_open
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1>  %if %0 >= 2
    76                              <1>  mov ebx, %2
    77                              <1>  %if %0 >= 3
    78                              <1>  mov ecx, %3
    79                              <1>  %if %0 = 4
    80                              <1>  mov edx, %4
    81                              <1>  %endif
    82                              <1>  %endif
    83                              <1>  %endif
    84 0000002A B805000000          <1>  mov eax, %1
    85 0000002F CD30                <1>  int 30h
   150                                  	;jc	short cat_7
   151                                  	; 05/03/2022 ; (+)
   152 00000031 7305                    	jnc	short cat_2
   153 00000033 E900010000              	jmp	cat_7
   154                                  cat_2:
   155                                  	; 05/03/2022
   156 00000038 89C6                    	mov	esi, eax
   157                                  	;mov	[esi], eax ; 05/03/2022
   158                                  	;mov	[esi], ax
   159                                  		;;mov	r0,0f
   160                                  		;;sys	open; 0:..; 0
   161                                  		;;bes	loop
   162                                  		;;mov	r0,fin
   163                                  
   164                                  	; 05/03/2022 ; (+)
   165                                  	; convert user's file number to inode number
   166                                  	; (get 34 byte inode details, inode num + inode)
   167                                  	; (get 66 byte inode details for runix 386 v1.2)
   168                                  	sys	_fstat, esi, iobuf 
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1>  %if %0 >= 2
    76 0000003A 89F3                <1>  mov ebx, %2
    77                              <1>  %if %0 >= 3
    78 0000003C B9[70010000]        <1>  mov ecx, %3
    79                              <1>  %if %0 = 4
    80                              <1>  mov edx, %4
    81                              <1>  %endif
    82                              <1>  %endif
    83                              <1>  %endif
    84 00000041 B81C000000          <1>  mov eax, %1
    85 00000046 CD30                <1>  int 30h
   169                                  	;jc	short cat_7
   170                                  	; 05/03/2022 ; (+)
   171 00000048 731A                    	jnc	short cat_f
   172 0000004A E9E0000000              	jmp	cat_k ; 15/06/2022
   173                                  
   174                                  rwcount:
   175                                  	; 15/06/2022
   176 0000004F 31D2                    	xor	edx, edx
   177 00000051 A0[73010000]            	mov	al, [iobuf+stat.mode+1]
   178 00000056 A880                    	test	al, 80h
   179 00000058 7507                    	jnz	short rwc_1
   180 0000005A A840                    	test	al, 40h ; block device ?
   181 0000005C 7503                    	jnz	short rwc_1 ; yes
   182                                  	; no, character device
   183                                  	; read/write count = 1
   184 0000005E FEC2                    	inc	dl
   185 00000060 C3                      	retn
   186                                  rwc_1:
   187                                  	; regular file or block device
   188                                  	; read/write count = 512
   189 00000061 B602                    	mov	dh, 2 ; edx = 512
   190 00000063 C3                      	retn
   191                                  	
   192                                  cat_f:
   193                                  	; 15/06/2022
   194 00000064 E8E6FFFFFF              	call	rwcount
   195 00000069 8915[6C010000]          	mov	[filerwc], edx
   196                                  cat_3:	
   197                                  	; 05/03/2022 ; (+)
   198                                  	; get inode number of current tty (stdin)
   199                                  	; (get 34 byte inode details, inode num + inode)
   200                                  	; (get 66 byte inode details for runix 386 v1.2)
   201                                  	;sys	_fstat, 0, iobuf 
   202                                  	;;jc	short cat_n
   203                                  	;mov	ecx, iobuf	
   204                                  	sys	_fstat, 0  ; get stdin file inode details
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1>  %if %0 >= 2
    76 0000006F BB00000000          <1>  mov ebx, %2
    77                              <1>  %if %0 >= 3
    78                              <1>  mov ecx, %3
    79                              <1>  %if %0 = 4
    80                              <1>  mov edx, %4
    81                              <1>  %endif
    82                              <1>  %endif
    83                              <1>  %endif
    84 00000074 B81C000000          <1>  mov eax, %1
    85 00000079 CD30                <1>  int 30h
   205                                  
   206                                  	; 15/06/2022
   207 0000007B E8CFFFFFFF              	call	rwcount
   208 00000080 8915[68010000]          	mov	[stdinrw], edx
   209                                  
   210                                  cat_n:	;;3:
   211                                  	; get keyboard status of console tty
   212 00000086 31DB                    	xor	ebx, ebx  ; 0
   213 00000088 31C9                    	xor	ecx, ecx ; 0
   214                                  	sys	_gtty
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1>  %if %0 >= 2
    76                              <1>  mov ebx, %2
    77                              <1>  %if %0 >= 3
    78                              <1>  mov ecx, %3
    79                              <1>  %if %0 = 4
    80                              <1>  mov edx, %4
    81                              <1>  %endif
    82                              <1>  %endif
    83                              <1>  %endif
    84 0000008A B820000000          <1>  mov eax, %1
    85 0000008F CD30                <1>  int 30h
   215                                  	; 15/06/2022
   216 00000091 21DB                    	and	ebx, ebx ; is there a waiting char ?
   217 00000093 753F                    	jnz	short cat_x ; yes
   218                                  
   219 00000095 08F6                    	or	dh, dh  ; is stdin a character device (tty) ?
   220 00000097 7540                    	jnz	short cat_p
   221                                  			; no, stdin is a file or block device
   222                                  
   223                                  	; is there a file to read ?
   224 00000099 09F6                    	or	esi, esi ; 05/03/2022
   225 0000009B 755F                    	jnz	short cat_r ; yes
   226                                  
   227                                  	; edx = [stdinrw]
   228                                  	sys	_read, 0, iobuf
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1>  %if %0 >= 2
    76 0000009D BB00000000          <1>  mov ebx, %2
    77                              <1>  %if %0 >= 3
    78 000000A2 B9[70010000]        <1>  mov ecx, %3
    79                              <1>  %if %0 = 4
    80                              <1>  mov edx, %4
    81                              <1>  %endif
    82                              <1>  %endif
    83                              <1>  %endif
    84 000000A7 B803000000          <1>  mov eax, %1
    85 000000AC CD30                <1>  int 30h
   229                                  		; read one char into [iobuf]
   230 000000AE 727B                    	jc	short cat_6 ; (ebx = 0)
   231                                  
   232 000000B0 803D[70010000]1B        	cmp	byte [iobuf], 1Bh ; 27 ; ESCape key ?
   233 000000B7 7505                    	jne	short cat_c 
   234                                  
   235 000000B9 E982000000              	jmp	cat_exit ; yes, exit
   236                                  
   237                                  cat_c:
   238                                  	; is there a file to read ?
   239                                  	;or	esi, esi ; 05/03/2022
   240                                  	;jnz	short cat_r ; yes
   241                                  
   242                                  	; 16/06/2022
   243                                  	;and	edx, edx
   244                                  	;jz	short cat_exit ; end of stdin file
   245                                  
   246                                  	;xor	eax, eax
   247                                  	;inc	al
   248 000000BE B001                    	mov	al, 1
   249                                  	; eax = 1	
   250 000000C0 803D[70010000]0D        	cmp	byte [iobuf], 0Dh ; carriage return ?
   251 000000C7 754D                    	jne	short cat_w
   252 000000C9 C605[71010000]0A        	mov	byte [iobuf+1], 0Ah ; line feed
   253 000000D0 FEC0                    	inc	al
   254                                  	; eax = 2
   255 000000D2 EB42                    	jmp	short cat_w
   256                                  
   257                                  cat_x:
   258 000000D4 80FB1B                  	cmp	bl, 1Bh ; 27 ; ESCape key ?
   259 000000D7 7467                    	je	short cat_exit ; yes, exit
   260                                  cat_p:
   261                                  	; edx = [stdinrw]
   262                                  	sys	_read, 0, iobuf
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1>  %if %0 >= 2
    76 000000D9 BB00000000          <1>  mov ebx, %2
    77                              <1>  %if %0 >= 3
    78 000000DE B9[70010000]        <1>  mov ecx, %3
    79                              <1>  %if %0 = 4
    80                              <1>  mov edx, %4
    81                              <1>  %endif
    82                              <1>  %endif
    83                              <1>  %endif
    84 000000E3 B803000000          <1>  mov eax, %1
    85 000000E8 CD30                <1>  int 30h
   263                                  		; read one char into [iobuf]
   264 000000EA 723F                    	jc	short cat_6 ; (ebx = 0)
   265                                  	
   266                                  	; eax = read count
   267                                  	; read (redirected) stdin at first then other files 
   268 000000EC 09C0                    	or	eax, eax
   269 000000EE 7526                    	jnz	short cat_w ; write bytes in buffer
   270                                  
   271                                  	; 16/06/2022
   272                                  	; trick to skip reading stdin file
   273 000000F0 31D2                    	xor	edx, edx
   274                                  	; edx = 0
   275 000000F2 8915[68010000]          	mov	[stdinrw], edx  ; end of stdin file
   276                                  	;jmp	short cat_c ; read (input) file
   277                                  
   278                                  	; is there a file to read ?
   279 000000F8 21F6                    	and	esi, esi
   280 000000FA 743C                    	jz	short cat_7 ; no
   281                                   
   282                                  cat_r:
   283                                  	; 05/03/2022
   284                                  	;mov	eax, [esi] ; file descriptor/number
   285                                  	;;mov	ax, [esi]
   286                                  	;
   287                                  	;sys	_read, eax, iobuf, 512 ; 16/07/2015
   288                                  	;;sys 	_read, eax, ibuf, 512 
   289                                  	;jc	short cat_6
   290                                  	; 15/06/2022
   291                                  	; 05/03/2022
   292                                  	; esi = file descriptor/number
   293                                  	sys	_read, esi, iobuf, [filerwc]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1>  %if %0 >= 2
    76 000000FC 89F3                <1>  mov ebx, %2
    77                              <1>  %if %0 >= 3
    78 000000FE B9[70010000]        <1>  mov ecx, %3
    79                              <1>  %if %0 = 4
    80 00000103 8B15[6C010000]      <1>  mov edx, %4
    81                              <1>  %endif
    82                              <1>  %endif
    83                              <1>  %endif
    84 00000109 B803000000          <1>  mov eax, %1
    85 0000010E CD30                <1>  int 30h
   294                                  		; read 512 chars into [iobuf]
   295                                  	;jc	short cat_6
   296 00000110 721D                    	jc	short cat_k ; 05/03/2022
   297                                  
   298                                  	; NOTE: If input file is a tty (keyboard)
   299                                  	;	only 1 byte will be read, by ignoring
   300                                  	;	byte count (512).
   301                                  	;	Retro UNIX 8086 v1 kernel ('rtty')
   302                                  	;	has been modified fot that.
   303                                  	;       Erdogan Tan (16/07/2015)
   304                                  	;
   305                                  
   306                                  	; 15/06/2022
   307 00000112 21C0                    	and	eax, eax ; EAX = 1 for tty (keyboard)
   308                                  	;jz	short cat_6
   309 00000114 7419                    	jz	short cat_k ; 05/03/2022
   310                                  
   311                                  ;	push	esi
   312                                  	;mov	esi, ibuf
   313                                  ;	mov	esi, ecx ; offset ibuf
   314                                  ;	mov	ecx, eax
   315                                  		;;mov	fin,r0
   316                                  		;;sys	read; ibuf; 512.
   317                                  		;;bes	3f
   318                                  		;;mov	r0,r4
   319                                  		;;beq	3f
   320                                  		;;mov	$ibuf,r3
   321                                  	 ; 16/07/2015
   322                                  ;	mov	edx, eax
   323                                  ;	;add	edx, obuf
   324                                  ;cat_4:
   325                                  ;	;;4:
   326                                  ;	lodsb
   327                                  	;call	putc
   328                                  cat_w:
   329                                  	; 16/07/2015
   330                                  	; write to console tty (stdout)
   331                                  	sys 	_write, 1, iobuf, eax
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1>  %if %0 >= 2
    76 00000116 BB01000000          <1>  mov ebx, %2
    77                              <1>  %if %0 >= 3
    78 0000011B B9[70010000]        <1>  mov ecx, %3
    79                              <1>  %if %0 = 4
    80 00000120 89C2                <1>  mov edx, %4
    81                              <1>  %endif
    82                              <1>  %endif
    83                              <1>  %endif
    84 00000122 B804000000          <1>  mov eax, %1
    85 00000127 CD30                <1>  int 30h
   332                                  	;jc	short cat_6
   333                                  	; 05/03/2022
   334                                  	;jnc	short cat_3
   335                                  	; 15/06/2022
   336 00000129 731F                    	jnc	short cat_8
   337                                  
   338                                  ;	loop	cat_4
   339                                  ;	pop	esi
   340                                  cat_5:
   341                                  	;mov	eax, [esi] ; 05/03/2022
   342                                  	;;mov	ax, [esi]
   343                                  	;jmp	short cat_3
   344                                  		;;movb	(r3)+,r0
   345                                  		;;jsr	pc,putc
   346                                  		;;dec	r4
   347                                  		;;bne	4b
   348                                  		;;br	3b
   349                                  	;; 05/03/2022
   350                                  	;; ebx = file descriptor/input
   351                                  	;;and	ebx, ebx ; console input ?
   352                                  	;;jnz	short cat_3 ; no, file input
   353                                  	;;cmp	byte [quit], al ; 0
   354                                  	;;ja	short cat_7 ; ebx = 0
   355                                  	;;jmp	short cat_z
   356                                  	; 05/03/2022
   357                                  	;jmp	short cat_3
   358                                  		
   359                                  cat_6:	;;3:
   360                                  	; 05/03/2022
   361                                  	; ebx = file descriptor/number
   362                                  	;movzx	ebx, word [esi]
   363                                  	;
   364 0000012B 09F6                    	or	esi, esi
   365 0000012D 7409                    	jz	short cat_7
   366                                  cat_k:
   367                                  	sys	_close, esi
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1>  %if %0 >= 2
    76 0000012F 89F3                <1>  mov ebx, %2
    77                              <1>  %if %0 >= 3
    78                              <1>  mov ecx, %3
    79                              <1>  %if %0 = 4
    80                              <1>  mov edx, %4
    81                              <1>  %endif
    82                              <1>  %endif
    83                              <1>  %endif
    84 00000131 B806000000          <1>  mov eax, %1
    85 00000136 CD30                <1>  int 30h
   368                                  	;
   369                                  	;or	ebx, ebx
   370                                  	;jz	short cat_7
   371                                  	;sys 	_close
   372                                  		;;mov	fin,r0
   373                                  		;;beq	loop
   374                                  		;;sys	close
   375                                  		;;br	loop
   376                                  cat_7:	
   377                                  	;;loop:
   378 00000138 4D                      	dec	ebp
   379                                  	;;jz	short cat_8
   380                                  	; 28/12/2015
   381                                  	;jg	short cat_0
   382                                  	; 05/03/2022
   383 00000139 7E05                    	jng	short cat_exit
   384 0000013B E9E2FEFFFF              	jmp	cat_0
   385                                  
   386                                  cat_exit:
   387                                  	sys	_exit
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1>  %if %0 >= 2
    76                              <1>  mov ebx, %2
    77                              <1>  %if %0 >= 3
    78                              <1>  mov ecx, %3
    79                              <1>  %if %0 = 4
    80                              <1>  mov edx, %4
    81                              <1>  %endif
    82                              <1>  %endif
    83                              <1>  %endif
    84 00000140 B801000000          <1>  mov eax, %1
    85 00000145 CD30                <1>  int 30h
   388                                  here:
   389 00000147 90                      	nop
   390 00000148 EBFD                    	jmp	short here
   391                                  	;;
   392                                  
   393                                  cat_8:
   394                                  	; 15/06/2022
   395 0000014A 39D0                    	cmp	eax, edx
   396 0000014C 72DD                    	jb	short cat_6
   397 0000014E 8B15[68010000]          	mov	edx, [stdinrw]
   398 00000154 09D2                    	or 	edx, edx  ; end of stdin file
   399 00000156 7405                    	jz	short cat_9
   400 00000158 E929FFFFFF              	jmp	cat_n
   401                                  
   402                                  cat_9:
   403                                  	; 16/06/2022
   404 0000015D 21F6                    	and	esi, esi
   405 0000015F 74CE                    	jz	short cat_k
   406 00000161 EB99                    	jmp	short cat_r
   407                                  
   408                                  ;cat_8:
   409                                  ;	;;done:
   410                                  ;	sub	di, obuf
   411                                  ;	jz	short cat_9
   412                                  ;	sys	_write, 1, obuf, di 
   413                                  		;;sub	$obuf,r2
   414                                  		;;beq	1f
   415                                  		;;mov	r2,0f
   416                                  		;;mov	$1,r0
   417                                  		;;sys	write; obuf; 0:..
   418                                  ;cat_9:	
   419                                  ;	;;1:
   420                                  ;	sys	_exit
   421                                  		;;sys	exit
   422                                  	;;
   423                                  ;putc:	
   424                                  ;	;;putc:
   425                                  ;	stosb
   426                                  ;	cmp	di, dx ; 16/07/2015
   427                                  	;cmp	di, obuf + 512
   428                                  ;	jb	short cat_10
   429                                  ;	push	cx
   430                                  	 ; 16/07/2015
   431                                  ;	mov	di, obuf
   432                                  ;	sub	dx, di ; byte (char) count
   433                                  	; 
   434                                  ;	sys 	_write, 1, obuf
   435                                  	;sys 	_write, 1, obuf, 512
   436                                  	;mov	di, obuf
   437                                  		;;movb	r0,(r2)+
   438                                  		;;cmp	r2,$obuf+512.
   439                                  		;;blo	1f
   440                                  		;;mov	$1,r0
   441                                  		;;sys	write; obuf; 512.
   442                                  		;;mov	$obuf,r2
   443                                  ;	pop	cx
   444                                  ;cat_10:	
   445                                  	;;1:
   446                                  ;	retn
   447                                  		;;rts	pc
   448                                  
   449 00000163 0D0A                    nl:	db 0Dh, 0Ah ; , 0
   450                                  
   451                                  ;; 05/03/2022
   452                                  ;quit:	db 0
   453                                  ;consoletty:
   454                                  ;	db '/dev/tty', 0 ; (+)
   455                                  
   456 00000165 90<rep 3h>              align 4
   457                                  
   458                                  bss_start:
   459                                  
   460                                  ABSOLUTE bss_start
   461                                  
   462                                  ; 15/06/2022
   463 00000168 ????????                stdinrw: resd 1
   464 0000016C ????????                filerwc: resd 1
   465                                  
   466 00000170 <res 200h>              iobuf:  resb 512
   467                                  ;ibuf:	resb 512
   468                                  ;obuf:	resb 512
   469                                  ;;fin:	resw 1
   470                                  ;fin:	resd 1 ; 05/03/2022	
   471                                  		;;.bss
   472                                  		;;ibuf:	.=.+512.
   473                                  		;;obuf:	.=.+512.
   474                                  		;;fin:	.=.+2
   475                                  		;;.text
   476                                  ;bss_end:
