1 Star 0 Fork 1

fengxueygr/asm_fragment

forked from 西边/asm_fragment 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
client.s 2.35 KB
一键复制 编辑 原始数据 按行查看 历史
西边 提交于 2021-09-20 11:11 . comit
/* client */
.LC0:
.string "127.0.0.1"
.LC1:
.string "please input:"
.LC2:
.string "end"
.LC3:
.string "%s\n"
.globl main
main:
pushq %rbp
movq %rsp,%rbp
subq $0x1000,%rsp
movl $0,-0x1000(%rbp) /* sockfd */
movl $0,-0xffc(%rbp) /* ser */
movl $0,-0xfec(%rbp) /* cli */
movl $0,-0xfdc(%rbp) /* res */
movl $0,-0xfd8(%rbp) /* buff */
movl $0,-0xf58(%rbp) /* recvbuff */
movl $0,%edx
movl $1,%esi
movl $2,%edi
movl $0,%eax
call socket
movl %eax,-0x1000(%rbp) /* sockfd */
movl $16,%edx
movl $0,%esi
leaq -0xffc(%rbp),%rdi /* ser */
movl $0,%eax
call memset
leaq -0xffc(%rbp),%rdi /* ser */
movw $2,0(%rdi) /* ser.sin_family */
movl $6000,%edi
movl $0,%eax
call htons
leaq -0xffc(%rbp),%rdi /* ser */
movw %ax,2(%rdi) /* ser.sin_port */
leaq .LC0(%rip),%rdi
movl $0,%eax
call inet_addr
leaq -0xffc(%rbp),%rdi /* ser */
movl %eax,4(%rdi) /* ser.sin_addr.s_addr */
movl $16,%edx
leaq -0xffc(%rbp),%rsi /* ser */
movl -0x1000(%rbp),%edi /* sockfd */
movl $0,%eax
call connect
movl %eax,-0xfdc(%rbp) /* res */
jmp .Lmain_400
.Lmain_500:
leaq .LC1(%rip),%rdi
movl $0,%eax
call printf
movq stdout(%rip),%rdi
movl $0,%eax
call fflush
movl $128,%edx
movl $0,%esi
leaq -0xfd8(%rbp),%rdi /* buff */
movl $0,%eax
call memset
movq stdin(%rip),%rdx
movl $128,%esi
leaq -0xfd8(%rbp),%rdi /* buff */
movl $0,%eax
call fgets
leaq -0xfd8(%rbp),%rdi /* buff */
movl $0,%eax
call strlen
subl $1,%eax
movslq %eax,%rax
leaq -0xfd8(%rbp),%rdi /* buff */
movb $0,0(%rdi,%rax,1) /* buff[strlen(buff)-1] */
leaq .LC2(%rip),%rsi /* end */
leaq -0xfd8(%rbp),%rdi /* buff */
movl $0,%eax
call strcmp
cmpl $0,%eax
jne .Lmain_450
jmp .Lmain_300 /* break */
.Lmain_450:
movl $0,%ecx
leaq -0xfd8(%rbp),%rdi /* buff */
movl $0,%eax
call strlen
movl %eax,%edx
leaq -0xfd8(%rbp),%rsi /* buff */
movl -0x1000(%rbp),%edi /* sockfd */
movl $0,%eax
call send
movl $128,%edx
movl $0,%esi
leaq -0xf58(%rbp),%rdi /* recvbuff */
movl $0,%eax
call memset
movl $0,%ecx
movl $127,%edx
leaq -0xf58(%rbp),%rsi /* recvbuff */
movl -0x1000(%rbp),%edi /* sockfd */
movl $0,%eax
call recv
leaq -0xf58(%rbp),%rsi /* recvbuff */
leaq .LC3(%rip),%rdi
movl $0,%eax
call printf
.Lmain_400:
jmp .Lmain_500
.Lmain_300:
movl -0x1000(%rbp),%edi /* sockfd */
movl $0,%eax
call close
movl $0,%eax
leave
ret
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fengxueygr/asm_fragment.git
git@gitee.com:fengxueygr/asm_fragment.git
fengxueygr
asm_fragment
asm_fragment
master

搜索帮助