News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Unknown relocation type (1) error

Started by valentin68, November 23, 2017, 03:08:42 AM

Previous topic - Next topic

valentin68

 0
down vote
favorite
   

I am good with M68000 but X86 is diffficult for me. I am trying to assemble this simple program with MASM

.MODEL SMALL
.data?
  ONE  dB ?
  TWO  dB ?
  stack db  100 dup(?)

.data
  MSG  db 13,10, 'Enter deree of polynomials:  $'
  MSG2 db 13,10, 'Enter coefficient of x^ $'
  MSG3 db 13,10, 'The polynomial created is: $'
  MSG4 db 13,10, 'The first derivative is: $'
  STR1 db  255 DUP('$')

.code

_start:

            mov ax, offset MSG
            mov ds, ax 

end _start

and I keep getting the error Unknown relocation type (1) for symbol MSG. I know what this is (it happens when the displacement is bigger than that allowed by the model or something like this) but I do not know how to solve this error (I know MASM is a 32 bit assembler and I am trying to write a 16 bit code). What I am trying to do is to load the pointer to .data into ds register.

Pretty please, help me!

aw27

try mov   ax, seg MSG instead of mov ax, offset MSG
(Untested)
And find a way to exit the program without crashing.

valentin68

Quote from: aw27 on November 23, 2017, 03:15:36 AM
try mov   ax, seg MSG instead of mov ax, offset MSG
(Untested)
And find a way to exit the program without crashing.

I get a symbol type conflict
also with
mov ax, segment MSG
syntax error segment

aw27


I told you SEG and why do you use SEGMENT?

valentin68

I used both seg  and segment
mov ax, seg msg      (symbol type conflict)
mov ax, segment msg (told on stackexchange by someone  - syntax error segment)

None works
I know MASM is 32 bit compiler, I am trying now to use a 16 bit compiler.

jj2007

No errors here 8)*** Assemble 16-bit app using mlv614 /c  /Fo "NewFile" ***
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: tmp_file.asm

*** Link using link16   ***

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.

LINK : warning L4021: no stack segment


Note that MSG is a structure defined in Windows.inc (which you don't include...):MSG STRUCT
  hwnd      DWORD      ?
  message   DWORD      ?
  wParam    DWORD      ?
  lParam    DWORD      ?
  time      DWORD      ?
  pt        POINT      <>
MSG ENDS


Have you tried MSG1? Do you use link16.exe?

valentin68

    Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: derivative 1.asm
derivative 1.asm(18) : error A2006: undefined symbol : DGROUP
_
Assembly Error
Press any key to continue . . .

I modified the MSG to MSG1  i still have errors
(MSG is a string in my program)


Can you paste please exactly the listing of the program that you have assembled?

jj2007

Quote from: valentin68 on November 23, 2017, 03:48:01 AMCan you paste please exactly the listing of the program that you have assembled?
.MODEL SMALL
.data?
  ONE  dB ?
  TWO  dB ?
  stack db  100 dup(?)

.data
  MSG  db 13,10, 'Enter deree of polynomials:  $'
  MSG2 db 13,10, 'Enter coefficient of x^ $'
  MSG3 db 13,10, 'The polynomial created is: $'
  MSG4 db 13,10, 'The first derivative is: $'
  STR1 db  255 DUP('$')

.code

_start:

            mov ax, offset MSG
            mov ds, ax

end _start


You may notice that this is exactly your code 8)

I just copied & pasted it into a File/New text file in RichMasm, and then hit F6. That builds fine and produces an error message saying that 16-bit applications are not allowed on my machine. Check your commandline options...

qWord

valentin68,
you must use the 16 bit aware linker (link16.exe). Then the code from first post will build.
MREAL macros - when you need floating point arithmetic while assembling!

jj2007

Warning: Proggie works fine on my WinXP VM but I had to move it to drive C: - "cannot execute xyz.exe" if it's a substituted drive.

aw27

This builds fine and does not crash.
Tested in DosBox



.186

.model  small

.stack  100h

.data?
  ONE  dB ?
  TWO  dB ?


.data
  MSG  db 13,10, 'Enter deree of polynomials:  $'
  MSG2 db 13,10, 'Enter coefficient of x^ $'
  MSG3 db 13,10, 'The polynomial created is: $'
  MSG4 db 13,10, 'The first derivative is: $'
  STR1 db  255 DUP('$')

.code

_start:

            mov ax, seg MSG
            mov ds, ax
    mov  ax, 4c00h       ; terminate program
    int 21h
end _start

valentin68

yes as someone above said I have to use the link16.exe
The same answer I've got from stackexchange.

Very hard to work on X86 (especially on 16 bit)

For those that do not know, I have written 10 000-20 000 pages (not lines) of M68000 code 25 years ago for UBISOFT (It took me half a year).
I was paid with 400 USD for this.
It was the game Celtic Legends for Atari 1000.

jj2007

Atari 1000? Or rather 520ST? Compliments in any case ;-)

aw27

Quote from: valentin68 on November 23, 2017, 04:47:09 AM
Very hard to work on X86 (especially on 16 bit)
Indeed, and if you have more x86 hard nuts like these  :shock: to crack be aware that there is a subforum called "16 bit DOS Programming". Not really popular these days, the last post was 4 months ago.

qWord

Quote from: valentin68 on November 23, 2017, 04:47:09 AMfor UBISOFT (It took me half a year).
I was paid with 400 USD for this.
Wow! 400$/(6*4*5*8h) = 42ct/h.
MREAL macros - when you need floating point arithmetic while assembling!