Author Topic: Error I'm getting in assembler  (Read 603 times)

lbwiley

  • Regular Member
  • *
  • Posts: 3
Error I'm getting in assembler
« on: June 14, 2019, 01:17:34 AM »
Errors I'm getting: LoganWileyproj3.obj : error LNK2001: unresolved external symbol _ExitProcess@4
LoganWileyproj3.exe : fatal error LNK1120: 1 unresolved externals

Tried a few things
Here's my code:
Code: [Select]
; LoganWileyproj3.asm - calculated the expression A = (A+B)-(C+D)
INCLUDE Irvine32.inc

.386
.model flat, stdcall
.stack 4096
ExitProcess proto, dwExitCode: dword
.code
main PROC
    ;assign the integer value to registers
    mov eax,150       ; A=EAX=150
    mov ebx,100        ; B=EBX=100
    mov ecx,50          ; C=ECX=50
    mov edx,40         ; D=EDX=40
    ; calculates the expression
    add eax,ebx         ; EAX= (A+B)
    add ecx,edx         ; ECX= (C+D)
    sub eax,ecx         ; EAX= (A+B) - (C+D)
    invoke ExitProcess,0
main ENDP
END MAIN

jj2007

  • Member
  • *****
  • Posts: 9794
  • Assembler is fun ;-)
    • MasmBasic
Re: Error I'm getting in assembler
« Reply #1 on: June 14, 2019, 01:53:03 AM »
Try to remove the comma after proto

lbwiley

  • Regular Member
  • *
  • Posts: 3
Re: Error I'm getting in assembler
« Reply #2 on: June 14, 2019, 02:27:02 AM »
Removing the comma didn't do anything still getting the same error.

tenkey

  • Regular Member
  • *
  • Posts: 19
Re: Error I'm getting in assembler
« Reply #3 on: June 14, 2019, 02:57:04 AM »
The linker is not finding kernel32.lib, which is where _ExitProcess@4 resides.
From your coding style, you will need to add kernel32.lib to the list of files the linker needs. You will need the full path name, unless the LIB environment variable is set properly to the .lib directory. The full pathname will depend on your Irvine configuration.

jj2007

  • Member
  • *****
  • Posts: 9794
  • Assembler is fun ;-)
    • MasmBasic
Re: Error I'm getting in assembler
« Reply #4 on: June 14, 2019, 04:47:29 AM »
This works:
Code: [Select]
.stack 4096
includelib \masm32\lib\Kernel32.lib

lbwiley

  • Regular Member
  • *
  • Posts: 3
Re: Error I'm getting in assembler
« Reply #5 on: June 14, 2019, 06:55:43 AM »
Thank you

jj2007

  • Member
  • *****
  • Posts: 9794
  • Assembler is fun ;-)
    • MasmBasic
Re: Error I'm getting in assembler
« Reply #6 on: June 14, 2019, 07:25:54 AM »
Sorry for my previous advice. The PROTO does indeed not need a comma, i.e. the normal syntax is someproc PROTO :DWORD, but that was not the problem. As tenkey wrote, it was the missing Kernel32.lib, which can be included either via includelib:
Code: [Select]
includelib \masm32\lib\Kernel32.libor by adding \masm32\lib\Kernel32.lib to the linker's commandline.

Btw if you have any intention to learn assembly seriously, dump Irvine and use the Masm32 SDK.

AW

  • Member
  • *****
  • Posts: 2435
  • Let's Make ASM Great Again!
Re: Error I'm getting in assembler
« Reply #7 on: June 14, 2019, 07:36:39 PM »
Irvine is not that bad, it teaches how to use Visual Studio with ASM and has a few interesting code samples.
It provides also a kernel32.lib and everything is freely downloadable.

It is always good to know what we are talking about before criticizing.