Author Topic: nasm + lld-link  (Read 281 times)

Offline NASM

  • Jr. Member
  • *
  • Posts: 2
nasm + lld-link
« on: September 12, 2018, 11:20:36 AM »
Help me pls import function


Code: [Select]
BITS 64

SECTION .bss

  hSocket:  resq 1

SECTION .data

port: equ 777

struc WSADATA
  .wVersion:  resw 1
  .wHighVersion:  resw 1
  .szDescription:  resb 256
  .szSystemStatus:  resb 256
  .iMaxSockets:  resd 1
  .iMaxUdpDg:  resd 1
  .lpVendorInfo:  resq 1
endstruc

struc sockaddr_in
  .sin_family:  resd 1
  .sin_port:  resd 1
  .sin_addr:  resq 1
  .sin_zero:  resb 8
  .size:
endstruc

SECTION .text

global start

extern WSAStartup
extern WSACleanup
extern socket
extern Sleep

extern ExitProcess
import ExitProcess kernel32.dll

extern accept
extern listen
extern bind

start:

  mov rdx , [WSADATA]
  mov rcx , 0x202
  call WSAStartup
 
  mov r8 , 0
  mov rdx , 1
  mov rcx , 2
  call socket
 
  mov [hSocket] , rax
  mov dword [sockaddr_in.sin_family] , 1
  mov qword [sockaddr_in.sin_addr] , 0
  mov ax , port
  xchg ah , al
  mov [sockaddr_in.sin_port] , ax
  mov r8 , sockaddr_in.size
  mov rdx , [sockaddr_in]
  mov rcx , hSocket
  call bind
 
  mov rdx , 13
  mov rcx , hSocket
  call listen
 
  mov r8 , 0
  mov rdx , [sockaddr_in]
  mov rcx , hSocket
  call accept
 
  mov rcx , 60000
  call Sleep
 
  call WSACleanup
 
  mov rcx,0
  call ExitProcess

C:\msys64\home\Alexey>nasm cmd.asm -f win64 -o cmd.obj
cmd.asm:39: error: parser: instruction expected


https://wasm.in/threads/lld-bsd-exe.32375/#post-402921

Offline fredericopissarra

  • New Member
  • Posts: 1
Re: nasm + lld-link
« Reply #1 on: September 18, 2018, 06:20:42 PM »
There is no "import" directive in NASM... All symbols resolution is made in linking phase...

Offline NASM

  • Jr. Member
  • *
  • Posts: 2
Re: nasm + lld-link
« Reply #2 on: November 08, 2018, 06:25:22 PM »
LLD BSD EXE
Wont write clear browser wif support MSHTML.DLL

WASM.IN FORUM