# ******************************************************************************** # lab6C.s (Client) # by Broken Sword [HI-TECH] # (for Linux based on Intel x86 only) # brokensword@mail.ru # http://subscribe.ru/catalog/comp.soft.prog.intelpm # rusfaq.ru # wasm.ru # Compile Instructions: # -------------------------------------------------------------------------------- # as lab6C.s # ld --strip-all -o lab6C a.out # ******************************************************************************** # ******************************************************************************** .include "syscalls.inc" .include "def.inc" .text .globl _start _start: pushl $0 # protocol pushl $SOCK_STREAM # type pushl $AF_INET # domain movl %ESP,%ECX movl $SYS_SOCKET,%EBX movl $SYS_socketcall,%EAX int $0x80 addl $0xC,%ESP movl %EAX,(sockfd) pushl $0x10 # addrlen pushl $sockaddr_in pushl %EAX # sockfd movl %ESP,%ECX movl $SYS_CONNECT,%EBX movl $SYS_socketcall,%EAX int $0x80 addl $0xC,%ESP _next_plain_text: xorl %EBX,%EBX # stdin movl $buf,%ECX # ECX->buf movl $1024,%EDX # 1024 bytes movl $SYS_read,%EAX int $0x80 # read from stdin movl (sockfd),%EBX movl $buf,%ECX # ECX->plain_text movl %EAX,%EDX # bytes read movl $SYS_write,%EAX int $0x80 # send plain_text movl $SYS_read,%EAX int $0x80 # wait chiper_text xorl %EBX,%EBX incl %EBX # EBX=1 (stdout) movl $SYS_write,%EAX int $0x80 # disp chiper_text jmp _next_plain_text # ******************************************************************************** .data sockfd: .long 0 sockaddr_in: sin_family: .word AF_INET sin_port: .word 0x3930 # port:12345 sin_addr: .long 0x0100007F # 127.0.0.1 buf: # ********************************************************************************