Copy stdin to stdout: Difference between revisions
Content added Content deleted
(add freebasic) |
Not a robot (talk | contribs) (Add 8086 assembly) |
||
Line 2: | Line 2: | ||
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line. |
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line. |
||
=={{header|8086 Assembly}}== |
|||
<lang asm>READ: equ 3Fh ; MS-DOS syscalls |
|||
WRITE: equ 40h |
|||
BUFSZ: equ 4000h ; Buffer size |
|||
cpu 8086 |
|||
bits 16 |
|||
org 100h |
|||
section .text |
|||
read: mov ah,READ ; Read into buffer |
|||
xor bx,bx ; From STDIN (file 0) |
|||
mov cx,BUFSZ |
|||
mov dx,buffer |
|||
int 21h |
|||
test ax,ax ; Did we read anything? |
|||
jz done ; If not, stop |
|||
xchg ax,cx ; Write as many bytes as read |
|||
mov ah,WRITE |
|||
inc bx ; To STDOUT (file 1) |
|||
int 21h |
|||
jmp read ; Go get more |
|||
done: ret |
|||
section .bss |
|||
buffer: resb BUFSZ</lang> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |