default.txt 898 B

123456789101112131415161718192021222324252627282930313233343536
  1. .text
  2. .global connect
  3. connect:
  4. mov r3, #2 ; s->sin_family = AF_INET
  5. strh r3, [sp]
  6. ldr r3, =server_port ; s->sin_port = server_port
  7. ldr r3, [r3]
  8. strh r3, [sp, #2]
  9. ldr r3, =server_addr ; s->sin_addr = server_addr
  10. ldr r3, [r3]
  11. str r3, [sp, #4]
  12. mov r3, #0 ; bzero(&s->sin_zero)
  13. str r3, [sp, #8]
  14. str r3, [sp, #12]
  15. mov r1, sp ; const struct sockaddr *addr = sp
  16. ldr r7, =connect_call
  17. ldr r7, [r7]
  18. swi #0
  19. add sp, sp, #16
  20. pop {r0} ; pop sockfd
  21. pop {r7}
  22. pop {fp, ip, lr}
  23. mov sp, ip
  24. bx lr
  25. .data
  26. socket_call: .long 281
  27. connect_call: .long 283
  28. /* all addresses are network byte-order (big-endian) */
  29. server_addr: .long 0x0100007f ; localhost
  30. server_port: .hword 0x0b1a