News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

HELP:FAIL TO LINK ERROR LNK1120

Started by heikezzaass, June 08, 2011, 03:43:32 PM

Previous topic - Next topic

heikezzaass

HI,mates,i'm new to assembly language and facing some problem:i have typed in some code to spy how asm be compiled and linked,but,the compile succeed while link failed.
HERE IS HINTS:fatal error LNK1120:1 unresolved externals. :dazzled:
i tried my best to find out where the problem comes from,but it seems all right.I tried on different PC but the problem still extists,so i turn to u 4 hlep.
Thanks a lot,here is the code,so short:
assume cs:codesg

codesg segment

    mov ax,2000h
    mov ss,ax
    mov sp,0h
    add sp,10
    pop ax
    pop bx
    push ax
    push bx
    pop ax
    pop bx
   
    mov ax,4c00h
    int 21h

codesg ends

end

dedndave

the only label you have is "codesg" - that must be the unresolved external
i thought the standard name was "codeseg"

however, you have not specified a model
also - this is 16-bit code - you must use a 16-bit linker
this program should assemble and run, if linked with Link16.exe...
        .MODEL  Small

        .DATA

TestMsg db 'Hello',0Dh,0Ah,24h

        .CODE
        ASSUME  DS:DGROUP

_main   PROC    FAR

        mov     ax,@DATA       ;@DATA is an alias for DGROUP
        mov     ds,ax

        mov     dx,offset TestMsg
        mov     ah,9
        int     21h

        mov     ax,4C00h
        int     21h

_main   ENDP

        END     _main


notice that the END directive describes the entry point

heikezzaass

Quote from: dedndave on June 08, 2011, 04:25:24 PM
the only label you have is "codesg" - that must be the unresolved external
i thought the standard name was "codeseg"

however, you have not specified a model
also - this is 16-bit code - you must use a 16-bit linker
this program should assemble and run, if linked with Link16.exe...
        .MODEL  Small

        .DATA

TestMsg db 'Hello',0Dh,0Ah,24h

        .CODE
        ASSUME  DS:DGROUP

_main   PROC    FAR

        mov     ax,@DATA       ;@DATA is an alias for DGROUP
        mov     ds,ax

        mov     dx,offset TestMsg
        mov     ah,9
        int     21h

        mov     ax,4C00h
        int     21h

_main   ENDP

        END     _main


notice that the END directive describes the entry point


Thanks so much,i have figured out what was wrong.as your hints,i changed the "codesg" to something else and used "link16.exe"which is under "/masm32/bin",unfortunately , it made no difference.However ,the words "you must use a 16-bit linker"caught my mind,maybe the problem is from the linker.So i downloaded a MS overlay linker v3.6,and threw it to MS-DOS(it doesn't fit my OS,win 7 x64...T-T )then linked the .obj to .exe successfully.It also run smoothly on DOS.SO,finally,the troubles gone.I'm very very appreciative of your help. :cheekygreen:

MichaelW

heikezzaass,

For your posted source, assembling with ML /c filename.asm and linking with Link16 filename.obj; I get two warnings from the linker:

LINK : warning L4021: no stack segment
LINK : warning L4038: program has no starting address

But the EXE runs OK.
eschew obfuscation