1 Star 0 Fork 1

fengxueygr/asm_fragment

forked from 西边/asm_fragment 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
server.s 2.46 KB
一键复制 编辑 原始数据 按行查看 历史
西边 提交于 2021-09-20 11:11 . comit
/* server */
.LC0:
.string "127.0.0.1"
.LC1:
.string "error\n"
.LC2:
.string "%d:%s\n"
.LC3:
.string "OK"
.LC4:
.string "one client over\n"
.globl main
main:
pushq %rbp
movq %rsp,%rbp
subq $0x1000,%rsp
movl $0,-0x1000(%rbp) /* sockfd */
movl $0,-0xff8(%rbp) /* ser */
movl $0,-0xfe8(%rbp) /* cli */
movl $0,-0xfd8(%rbp) /* res */
movl $0,-0xfd4(%rbp) /* len */
movl $0,-0xfd0(%rbp) /* c */
movl $0,-0xfcc(%rbp) /* n */
movl $0,-0xfc8(%rbp) /* recvbuf */
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 -0xff8(%rbp),%rdi /* ser */
movl $0,%eax
call memset
leaq -0xff8(%rbp),%rdi /* ser */
movw $2,0(%rdi) /* ser.sin_family */
movl $6000,%edi
movl $0,%eax
call htons
leaq -0xff8(%rbp),%rdi /* ser */
movw %ax,2(%rdi) /* ser.sin_port */
leaq .LC0(%rip),%rdi
movl $0,%eax
call inet_addr
leaq -0xff8(%rbp),%rdi /* ser */
movl %eax,4(%rdi) /* ser.sin_addr.s_addr */
movl $16,%edx
leaq -0xff8(%rbp),%rsi /* ser */
movl -0x1000(%rbp),%edi /* sockfd */
movl $0,%eax
call bind
movl %eax,-0xfd8(%rbp) /* res */
movl $5,%esi
movl -0x1000(%rbp),%edi /* sockfd */
movl $0,%eax
call listen
jmp .Lmain_400
.Lmain_500:
movl $16,-0xfd4(%rbp) /* len */
leaq -0xfd4(%rbp),%rdx /* len */
leaq -0xfe8(%rbp),%rsi /* cli */
movl -0x1000(%rbp),%edi /* sockfd */
movl $0,%eax
call accept
movl %eax,-0xfd0(%rbp) /* c */
cmpl $0,-0xfd0(%rbp) /* c */
jge .Lmain_490
leaq .LC1(%rip),%rdi
movl $0,%eax
call perror
jmp .Lmain_500 /* continue */
.Lmain_490:
jmp .Lmain_450
.Lmain_489:
movl $128,%edx
movl $0,%esi
leaq -0xfc8(%rbp),%rdi /* recvbuf */
movl $0,%eax
call memset
movl $0,%ecx
movl $127,%edx
leaq -0xfc8(%rbp),%rsi /* recvbuf */
movl -0xfd0(%rbp),%edi /* c */
movl $0,%eax
call recv
movl %eax,-0xfcc(%rbp) /* n */
cmpl $0,-0xfcc(%rbp) /* n */
jg .Lmain_470
leaq .LC4(%rip),%rdi
movl $0,%eax
call printf
jmp .Lmain_440 /* break */
.Lmain_470:
leaq -0xfc8(%rbp),%rdx /* recvbuf */
movl -0xfd0(%rbp),%esi /* c */
leaq .LC2(%rip),%rdi
movl $0,%eax
call printf
movl $0,%ecx
movl $2,%edx
leaq .LC3(%rip),%rsi /* */
movl -0xfd0(%rbp),%edi /* c */
movl $0,%eax
call send
.Lmain_450:
jmp .Lmain_489
.Lmain_440:
movl -0xfd0(%rbp),%edi /* c */
movl $0,%eax
call close
.Lmain_400:
jmp .Lmain_500
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

搜索帮助