PageRenderTime 28ms CodeModel.GetById 2ms app.highlight 22ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/nasm/socket.asm

https://android.googlesource.com/toolchain/yasm
Assembly | 1513 lines | 613 code | 900 blank | 0 comment | 0 complexity | ceddce4c2cacb1e82c505ffd0263414b MD5 | raw file
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33INADDR_ANY		equ	0
  34INADDR_LOOPBACK		equ	7F000001h
  35INADDR_BROADCAST	equ	0FFFFFFFFh
  36INADDR_NONE		equ	0FFFFFFFFh
  37
  38SOCK_STREAM		equ	1
  39SOCK_DGRAM		equ	2
  40
  41SOCKEVENT_READ		equ	01h
  42SOCKEVENT_WRITE		equ	02h
  43SOCKEVENT_OOB		equ	04h
  44SOCKEVENT_ACCEPT	equ	08h
  45SOCKEVENT_CONNECT	equ	10h
  46SOCKEVENT_CLOSE		equ	20h
  47
  48
  49[absolute 0]
  50SOCKADDR:
  51.Port		resw	1
  52.Address	resd	1
  53SOCKADDR_size:
  54[section .text]
  55
  56[absolute 0]
  57HOSTENT:
  58.Name		resd	1
  59.Aliases	resd	1
  60
  61.AddrList	resd	1
  62
  63HOSTENT_size:
  64[section .text]
  65
  66
  67
  68
  69
  70
  71[extern DPMI_Int]
  72[extern _AllocTransferBuf]
  73[extern _FreeTransferBuf]
  74
  75[extern DPMI_Regs]
  76[extern DPMI_EDI]
  77[extern DPMI_ESI]
  78[extern DPMI_EBP]
  79[extern DPMI_EBX]
  80[extern DPMI_EDX]
  81[extern DPMI_ECX]
  82[extern DPMI_EAX]
  83[extern DPMI_FLAGS]
  84[extern DPMI_ES]
  85[extern DPMI_DS]
  86[extern DPMI_FS]
  87[extern DPMI_GS]
  88[extern DPMI_SP]
  89[extern DPMI_SS]
  90
  91[extern _Transfer_Buf]
  92[extern _Transfer_Buf_Seg]
  93[extern _Transfer_Buf_Size]
  94
  95DPMI_EDI_off    equ     00h
  96DPMI_ESI_off    equ     04h
  97DPMI_EBP_off    equ     08h
  98
  99DPMI_EBX_off    equ     10h
 100DPMI_EDX_off    equ     14h
 101DPMI_ECX_off    equ     18h
 102DPMI_EAX_off    equ     1Ch
 103DPMI_FLAGS_off  equ     20h
 104DPMI_ES_off     equ     22h
 105DPMI_DS_off     equ     24h
 106DPMI_FS_off     equ     26h
 107DPMI_GS_off     equ     28h
 108DPMI_IP_off     equ     2Ah
 109DPMI_CS_off     equ     2Ch
 110DPMI_SP_off     equ     2Eh
 111DPMI_SS_off     equ     30h
 112
 113
 114
 115
 116
 117[extern _AllocMem]
 118[extern _AllocSelector]
 119[extern _FreeSelector]
 120[extern _GetPhysicalMapping]
 121[extern _FreePhysicalMapping]
 122[extern _LockArea]
 123
 124_AllocMem_arglen		equ	4
 125_AllocSelector_arglen		equ	4
 126_FreeSelector_arglen		equ	2
 127_GetPhysicalMapping_arglen      equ     16
 128_FreePhysicalMapping_arglen     equ     8
 129_LockArea_arglen                equ     10
 130
 131
 132
 133
 134
 135[extern _Install_Int]
 136[extern _Remove_Int]
 137[extern _Exit_IRQ]
 138[extern _Init_IRQ]
 139[extern _Restore_IRQ]
 140[extern _Enable_IRQ]
 141[extern _Disable_IRQ]
 142
 143_Install_Int_arglen             equ     8
 144_Remove_Int_arglen              equ     4
 145_Restore_IRQ_arglen             equ     4
 146_Enable_IRQ_arglen              equ     4
 147_Disable_IRQ_arglen             equ     4
 148
 149[bits 32]
 150
 151
 152
 153
 154SOCKET_INIT		equ	5001h
 155SOCKET_EXIT		equ	5002h
 156SOCKET_ACCEPT		equ	5003h
 157SOCKET_BIND		equ	5004h
 158SOCKET_CLOSE		equ	5005h
 159SOCKET_CONNECT		equ	5006h
 160SOCKET_GETPEERNAME	equ	5007h
 161SOCKET_GETSOCKNAME	equ	5008h
 162SOCKET_INETADDR		equ	5009h
 163SOCKET_INETNTOA		equ	500Ah
 164SOCKET_LISTEN		equ	500Bh
 165SOCKET_RECV		equ	500Ch
 166SOCKET_RECVFROM		equ	500Dh
 167SOCKET_SEND		equ	500Eh
 168SOCKET_SENDTO		equ	500Fh
 169SOCKET_SHUTDOWN		equ	5010h
 170SOCKET_CREATE		equ	5011h
 171SOCKET_GETHOSTBYADDR	equ	5012h
 172SOCKET_GETHOSTBYNAME	equ	5013h
 173SOCKET_GETHOSTNAME	equ	5014h
 174SOCKET_INSTALLCALLBACK	equ	5015h
 175SOCKET_REMOVECALLBACK	equ	5016h
 176SOCKET_ADDCALLBACK	equ	5017h
 177SOCKET_GETCALLBACKINFO	equ	5018h
 178
 179
 180STRING_MAX		equ	256
 181HOSTENT_ALIASES_MAX	equ	16
 182HOSTENT_ADDRLIST_MAX	equ	16
 183
 184[section .bss]
 185
 186Callback_Address	resd	1
 187Callback_Int		resb	1
 188Multiplex_Handle	resw	1
 189VDD_Handle		resw	1
 190LastError		resd	1
 191NetAddr_static		resb	STRING_MAX
 192HostEnt_Name_static	resb	STRING_MAX
 193HostEnt_Aliases_static	resd	HOSTENT_ALIASES_MAX
 194HostEnt_AddrList_static	resd	HOSTENT_ADDRLIST_MAX
 195HostEnt_Aliases_data	resb	STRING_MAX*HOSTENT_ALIASES_MAX
 196HostEnt_AddrList_data	resd	HOSTENT_ADDRLIST_MAX
 197
 198[section .data]
 199
 200rcsid	db	'$Id: socket.asm,v 1.1 2001/11/21 08:41:53 peter Exp $',0
 201
 202ALTMPX_Signature	db	'ECE291  ', 'EX291   ', 0
 203ALTMPX_MinVersion	equ	0100h
 204SOCKET_Version		equ	0100h
 205HostEnt_static	:
 206..@44.strucstart:
 207times HOSTENT.Name-($-..@44.strucstart) db 0
 208dd	HostEnt_Name_static
 209times HOSTENT.Aliases-($-..@44.strucstart) db 0
 210dd	HostEnt_Aliases_static
 211times HOSTENT.AddrList-($-..@44.strucstart) db 0
 212dd	HostEnt_AddrList_static
 213times HOSTENT_size-($-..@44.strucstart) db 0
 214
 215
 216VDD_InitData
 217	dw	SOCKET_Version
 218	dd	STRING_MAX
 219	dd	HOSTENT_ALIASES_MAX
 220	dd	HOSTENT_ADDRLIST_MAX
 221	dd	LastError
 222	dd	NetAddr_static
 223	dd	HostEnt_Name_static
 224	dd	HostEnt_Aliases_static
 225	dd	HostEnt_AddrList_static
 226	dd	HostEnt_Aliases_data
 227	dd	HostEnt_AddrList_data
 228
 229[section .text]
 230
 231
 232
 233
 234
 235
 236
 237[global _InitSocket]
 238_InitSocket
 239	push	esi
 240	push	edi
 241	push	es
 242
 243
 244
 245	cld
 246
 247
 248	xor	eax, eax
 249	mov	cx, 1
 250	int	31h
 251	jc	near .error
 252	mov	bx, ax
 253
 254
 255	mov	ax, 0008h
 256	xor	ecx, ecx
 257	mov	dx, 0FFFFh
 258	int	31h
 259	jc	near .errorfree
 260
 261	xor	eax, eax
 262
 263.loop:
 264	mov	esi, eax
 265	mov	[DPMI_EAX], eax
 266	push	bx
 267	mov	bx, 2Dh
 268	call	DPMI_Int
 269	pop	bx
 270	cmp	byte [DPMI_EAX], 0FFh
 271	jne	.next
 272
 273
 274	cmp	word [DPMI_ECX], ALTMPX_MinVersion
 275	jb	.next
 276
 277
 278	mov	ax, 0007h
 279	movzx	edx, word [DPMI_EDX]
 280	shl	edx, 4
 281	mov	ecx, edx
 282	shr	ecx, 16
 283	int	31h
 284	jc	.errorfree
 285
 286	mov	es, ebx
 287	movzx	edi, word [DPMI_EDI]
 288	mov	ecx, 16/2
 289	mov	esi, ALTMPX_Signature
 290	rep	cmpsw
 291	jz	.foundmpx
 292
 293.next:
 294	inc	ah
 295	jnz	.loop
 296
 297	jmp	short .errorfree
 298
 299.foundmpx:
 300
 301	mov	ax, 0001h
 302	int	31h
 303
 304
 305	mov	eax, [DPMI_EAX]
 306	mov	[Multiplex_Handle], ax
 307	mov	al, 10h
 308	mov	[DPMI_EAX], ax
 309	push	bx
 310	mov	bx, 2Dh
 311	call	DPMI_Int
 312	pop	bx
 313	cmp	byte [DPMI_EAX], 1
 314	jne	.error
 315	mov	dx, [DPMI_EDX]
 316	mov	[VDD_Handle], dx
 317
 318
 319	mov	ecx, VDD_InitData
 320	clc
 321	movzx	eax, word [VDD_Handle]
 322	or	eax, SOCKET_INIT<<16
 323	db	0C4h, 0C4h, 058h, 002h
 324	jc	.error
 325
 326	xor	eax, eax
 327	jmp	short .exit
 328
 329.errorfree:
 330	mov	ax, 0001h
 331	int	31h
 332
 333.error:
 334	xor	eax, eax
 335	inc	eax
 336
 337.exit:
 338	pop	es
 339	pop	edi
 340	pop	esi
 341	ret	
 342
 343
 344
 345
 346
 347
 348
 349[global _ExitSocket]
 350_ExitSocket
 351
 352	clc
 353	movzx	eax, word [VDD_Handle]
 354	or	eax, SOCKET_EXIT<<16
 355	db	0C4h, 0C4h, 058h, 002h
 356	ret	
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368[global _Socket_SetCallback]
 369_Socket_SetCallback:       push  ebp
 370          mov   ebp, esp
 371
 372
 373.HandlerAddress       equ 8
 374
 375
 376
 377
 378
 379	mov	ax, [Multiplex_Handle]
 380	mov	al, 11h
 381	mov	[DPMI_EAX], ax
 382	mov	bx, 2Dh
 383	call	DPMI_Int
 384	cmp	byte [DPMI_EAX], 1
 385	jne	near .error
 386
 387	movzx	edx, byte [DPMI_EDX]
 388	mov	[Callback_Int], dl
 389
 390	mov	ecx, [Callback_Address]
 391	mov	eax, [ebp+.HandlerAddress]
 392	mov	[Callback_Address], eax
 393	test	eax, eax
 394	jz	near .deinstall
 395
 396	test	ecx, ecx
 397	jnz	near .ok
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408                push dword 4
 409
 410
 411
 412
 413
 414
 415
 416
 417                push dword Callback_Address
 418
 419
 420
 421
 422
 423
 424
 425
 426                o16 push ds
 427
 428call _LockArea
 429        add esp, byte _LockArea_arglen
 430
 431
 432
 433
 434
 435
 436
 437
 438                push dword 1
 439
 440
 441
 442
 443
 444
 445
 446
 447                push dword Callback_Int
 448
 449
 450
 451
 452
 453
 454
 455
 456                o16 push ds
 457
 458call _LockArea
 459        add esp, byte _LockArea_arglen
 460
 461
 462
 463
 464
 465
 466
 467
 468                push dword Socket_InterruptHandler_end-Socket_InterruptHandler
 469
 470
 471
 472
 473
 474
 475
 476
 477                push dword Socket_InterruptHandler
 478
 479
 480
 481
 482
 483
 484
 485
 486                o16 push cs
 487
 488call _LockArea
 489        add esp, byte _LockArea_arglen
 490	movzx	edx, byte [DPMI_EDX]
 491
 492
 493
 494
 495
 496
 497
 498
 499                push dword Socket_InterruptHandler
 500
 501
 502
 503
 504
 505
 506
 507
 508                push edx
 509
 510call _Install_Int
 511        add esp, byte _Install_Int_arglen
 512	test	eax, eax
 513	jnz	.error
 514
 515	movzx	edx, byte [Callback_Int]
 516	clc
 517	movzx	eax, word [VDD_Handle]
 518	or	eax, SOCKET_INSTALLCALLBACK<<16
 519	db	0C4h, 0C4h, 058h, 002h
 520	test	eax, eax
 521	jz	.end
 522
 523	mov	dword [Callback_Address], 0
 524
 525
 526
 527
 528
 529
 530
 531
 532                push edx
 533
 534call _Remove_Int
 535        add esp, byte _Remove_Int_arglen
 536	jmp	short .error
 537
 538.deinstall:
 539	clc
 540	movzx	eax, word [VDD_Handle]
 541	or	eax, SOCKET_REMOVECALLBACK<<16
 542	db	0C4h, 0C4h, 058h, 002h
 543
 544
 545
 546
 547
 548
 549
 550
 551                push edx
 552
 553call _Remove_Int
 554        add esp, byte _Remove_Int_arglen
 555	xor	eax, eax
 556	jmp	short .end
 557
 558.ok:
 559	xor	eax, eax
 560	mov	esp, ebp
 561	pop	ebp
 562	ret	
 563.error:
 564	xor	eax, eax
 565	inc	eax
 566.end:
 567	mov	esp, ebp
 568	pop	ebp
 569	ret	
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599[global _Socket_AddCallback]
 600_Socket_AddCallback:       push  ebp
 601          mov   ebp, esp
 602
 603
 604.Socket       equ 8
 605
 606
 607.EventMask       equ 12
 608
 609
 610
 611	clc
 612	movzx	eax, word [VDD_Handle]
 613	or	eax, SOCKET_ADDCALLBACK<<16
 614	db	0C4h, 0C4h, 058h, 002h
 615	mov	esp, ebp
 616	pop	ebp
 617	ret	
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630Socket_InterruptHandler
 631
 632	mov	eax, [Callback_Address]
 633	test	eax, eax
 634	jz	.chain
 635
 636	clc
 637	movzx	eax, word [VDD_Handle]
 638	or	eax, SOCKET_GETCALLBACKINFO<<16
 639	db	0C4h, 0C4h, 058h, 002h
 640	test	eax, eax
 641	jnz	.chain
 642
 643	push	edx
 644	push	ecx
 645	call	dword [Callback_Address]
 646	add	esp, byte 8
 647
 648.done:
 649
 650	mov	al, 20h
 651	cmp	byte [Callback_Int], 50h
 652	jb	.lowirq
 653	out	0A0h, al
 654.lowirq:
 655	out	20h, al
 656
 657	xor	eax, eax
 658	ret	
 659
 660.chain:
 661	mov	eax, 1
 662	ret	
 663Socket_InterruptHandler_end
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675[global _Socket_accept]
 676_Socket_accept:       push  ebp
 677          mov   ebp, esp
 678
 679
 680.Socket       equ 8
 681
 682
 683.Name       equ 12
 684
 685
 686
 687	clc
 688	movzx	eax, word [VDD_Handle]
 689	or	eax, SOCKET_ACCEPT<<16
 690	db	0C4h, 0C4h, 058h, 002h
 691	mov	esp, ebp
 692	pop	ebp
 693	ret	
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714[global _Socket_bind]
 715_Socket_bind:       push  ebp
 716          mov   ebp, esp
 717
 718
 719.Socket       equ 8
 720
 721
 722.Name       equ 12
 723
 724
 725
 726	clc
 727	movzx	eax, word [VDD_Handle]
 728	or	eax, SOCKET_BIND<<16
 729	db	0C4h, 0C4h, 058h, 002h
 730	mov	esp, ebp
 731	pop	ebp
 732	ret	
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751[global _Socket_close]
 752_Socket_close:       push  ebp
 753          mov   ebp, esp
 754
 755
 756.Socket       equ 8
 757
 758
 759
 760	clc
 761	movzx	eax, word [VDD_Handle]
 762	or	eax, SOCKET_CLOSE<<16
 763	db	0C4h, 0C4h, 058h, 002h
 764	mov	esp, ebp
 765	pop	ebp
 766	ret	
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787[global _Socket_connect]
 788_Socket_connect:       push  ebp
 789          mov   ebp, esp
 790
 791
 792.Socket       equ 8
 793
 794
 795.Name       equ 12
 796
 797
 798
 799	clc
 800	movzx	eax, word [VDD_Handle]
 801	or	eax, SOCKET_CONNECT<<16
 802	db	0C4h, 0C4h, 058h, 002h
 803	mov	esp, ebp
 804	pop	ebp
 805	ret	
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826[global _Socket_getpeername]
 827_Socket_getpeername:       push  ebp
 828          mov   ebp, esp
 829
 830
 831.Socket       equ 8
 832
 833
 834.Name       equ 12
 835
 836
 837
 838	clc
 839	movzx	eax, word [VDD_Handle]
 840	or	eax, SOCKET_GETPEERNAME<<16
 841	db	0C4h, 0C4h, 058h, 002h
 842	mov	esp, ebp
 843	pop	ebp
 844	ret	
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865[global _Socket_getsockname]
 866_Socket_getsockname:       push  ebp
 867          mov   ebp, esp
 868
 869
 870.Socket       equ 8
 871
 872
 873.Name       equ 12
 874
 875
 876
 877	clc
 878	movzx	eax, word [VDD_Handle]
 879	or	eax, SOCKET_GETSOCKNAME<<16
 880	db	0C4h, 0C4h, 058h, 002h
 881	mov	esp, ebp
 882	pop	ebp
 883	ret	
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902[global _Socket_ntohl]
 903_Socket_ntohl
 904
 905
 906
 907
 908
 909
 910
 911[global _Socket_htonl]
 912_Socket_htonl:       push  ebp
 913          mov   ebp, esp
 914
 915
 916.HostVal       equ 8
 917
 918
 919
 920	mov	eax, [ebp+.HostVal]
 921	bswap	eax
 922
 923	mov	esp, ebp
 924	pop	ebp
 925	ret	
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944[global _Socket_ntohs]
 945_Socket_ntohs
 946
 947
 948
 949
 950
 951
 952
 953[global _Socket_htons]
 954_Socket_htons:       push  ebp
 955          mov   ebp, esp
 956
 957
 958.HostVal       equ 8
 959
 960
 961
 962	mov	ax, [ebp+.HostVal]
 963	xchg	al, ah
 964	mov	esp, ebp
 965	pop	ebp
 966	ret	
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987[global _Socket_inet_addr]
 988_Socket_inet_addr:       push  ebp
 989          mov   ebp, esp
 990
 991
 992.DottedAddress       equ 8
 993
 994
 995
 996	clc
 997	movzx	eax, word [VDD_Handle]
 998	or	eax, SOCKET_INETADDR<<16
 999	db	0C4h, 0C4h, 058h, 002h
1000	mov	esp, ebp
1001	pop	ebp
1002	ret	
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023[global _Socket_inet_ntoa]
1024_Socket_inet_ntoa:       push  ebp
1025          mov   ebp, esp
1026
1027
1028.Address       equ 8
1029
1030
1031
1032	clc
1033	movzx	eax, word [VDD_Handle]
1034	or	eax, SOCKET_INETNTOA<<16
1035	db	0C4h, 0C4h, 058h, 002h
1036	mov	eax, NetAddr_static
1037	mov	esp, ebp
1038	pop	ebp
1039	ret	
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061[global _Socket_listen]
1062_Socket_listen:       push  ebp
1063          mov   ebp, esp
1064
1065
1066.Socket       equ 8
1067
1068
1069.BackLog       equ 12
1070
1071
1072
1073	clc
1074	movzx	eax, word [VDD_Handle]
1075	or	eax, SOCKET_LISTEN<<16
1076	db	0C4h, 0C4h, 058h, 002h
1077	mov	esp, ebp
1078	pop	ebp
1079	ret	
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106[global _Socket_recv]
1107_Socket_recv:       push  ebp
1108          mov   ebp, esp
1109
1110
1111.Socket       equ 8
1112
1113
1114.Buf       equ 12
1115
1116
1117.MaxLen       equ 16
1118
1119
1120.Flags       equ 20
1121
1122
1123
1124	clc
1125	movzx	eax, word [VDD_Handle]
1126	or	eax, SOCKET_RECV<<16
1127	db	0C4h, 0C4h, 058h, 002h
1128	mov	esp, ebp
1129	pop	ebp
1130	ret	
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159[global _Socket_recvfrom]
1160_Socket_recvfrom:       push  ebp
1161          mov   ebp, esp
1162
1163
1164.Socket       equ 8
1165
1166
1167.Buf       equ 12
1168
1169
1170.MaxLen       equ 16
1171
1172
1173.Flags       equ 20
1174
1175
1176.From       equ 24
1177
1178
1179
1180	clc
1181	movzx	eax, word [VDD_Handle]
1182	or	eax, SOCKET_RECVFROM<<16
1183	db	0C4h, 0C4h, 058h, 002h
1184	mov	esp, ebp
1185	pop	ebp
1186	ret	
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210[global _Socket_send]
1211_Socket_send:       push  ebp
1212          mov   ebp, esp
1213
1214
1215.Socket       equ 8
1216
1217
1218.Buf       equ 12
1219
1220
1221.Len       equ 16
1222
1223
1224.Flags       equ 20
1225
1226
1227
1228	clc
1229	movzx	eax, word [VDD_Handle]
1230	or	eax, SOCKET_SEND<<16
1231	db	0C4h, 0C4h, 058h, 002h
1232	mov	esp, ebp
1233	pop	ebp
1234	ret	
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259[global _Socket_sendto]
1260_Socket_sendto:       push  ebp
1261          mov   ebp, esp
1262
1263
1264.Socket       equ 8
1265
1266
1267.Buf       equ 12
1268
1269
1270.Len       equ 16
1271
1272
1273.Flags       equ 20
1274
1275
1276.To       equ 24
1277
1278
1279
1280	clc
1281	movzx	eax, word [VDD_Handle]
1282	or	eax, SOCKET_SENDTO<<16
1283	db	0C4h, 0C4h, 058h, 002h
1284	mov	esp, ebp
1285	pop	ebp
1286	ret	
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312[global _Socket_shutdown]
1313_Socket_shutdown:       push  ebp
1314          mov   ebp, esp
1315
1316
1317.Socket       equ 8
1318
1319
1320.Flags       equ 12
1321
1322
1323
1324	mov	eax, [ebp+.Flags]
1325	test	eax, eax
1326	jz	.done
1327
1328	clc
1329	movzx	eax, word [VDD_Handle]
1330	or	eax, SOCKET_SHUTDOWN<<16
1331	db	0C4h, 0C4h, 058h, 002h
1332.done:
1333	mov	esp, ebp
1334	pop	ebp
1335	ret	
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356[global _Socket_create]
1357_Socket_create:       push  ebp
1358          mov   ebp, esp
1359
1360
1361.Type       equ 8
1362
1363
1364
1365	clc
1366	movzx	eax, word [VDD_Handle]
1367	or	eax, SOCKET_CREATE<<16
1368	db	0C4h, 0C4h, 058h, 002h
1369	mov	esp, ebp
1370	pop	ebp
1371	ret	
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392[global _Socket_gethostbyaddr]
1393_Socket_gethostbyaddr:       push  ebp
1394          mov   ebp, esp
1395
1396
1397.Address       equ 8
1398
1399
1400
1401	clc
1402	movzx	eax, word [VDD_Handle]
1403	or	eax, SOCKET_GETHOSTBYADDR<<16
1404	db	0C4h, 0C4h, 058h, 002h
1405	test	eax, eax
1406	jz	.done
1407	mov	eax, HostEnt_static
1408.done:
1409	mov	esp, ebp
1410	pop	ebp
1411	ret	
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431[global _Socket_gethostbyname]
1432_Socket_gethostbyname:       push  ebp
1433          mov   ebp, esp
1434
1435
1436.Name       equ 8
1437
1438
1439
1440	clc
1441	movzx	eax, word [VDD_Handle]
1442	or	eax, SOCKET_GETHOSTBYNAME<<16
1443	db	0C4h, 0C4h, 058h, 002h
1444	test	eax, eax
1445	jz	.done
1446	mov	eax, HostEnt_static
1447.done:
1448	mov	esp, ebp
1449	pop	ebp
1450	ret	
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471[global _Socket_gethostname]
1472_Socket_gethostname:       push  ebp
1473          mov   ebp, esp
1474
1475
1476.Name       equ 8
1477
1478
1479.NameLen       equ 12
1480
1481
1482
1483	clc
1484	movzx	eax, word [VDD_Handle]
1485	or	eax, SOCKET_GETHOSTNAME<<16
1486	db	0C4h, 0C4h, 058h, 002h
1487	mov	esp, ebp
1488	pop	ebp
1489	ret	
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508[global _Socket_GetLastError]
1509_Socket_GetLastError
1510
1511	mov	eax, [LastError]
1512	ret	
1513