F
F
fsociety_one2020-06-23 21:50:42
assembler
fsociety_one, 2020-06-23 21:50:42

Move truncated in place: R_386_16 at undefined symbol ".data"?

Good evening, colleagues. What is the essence of the error, there is a cycle on jmp, which must be executed 3 times, in the processes of which it first displays one frame (lines 16-20), then the array value, zero in the first circle, first in the second, etc. (22 - 28) and the second frame, after which it repeats.

section .text
        global _start    

_start:
        mov	edx, lenBT
        mov	ecx, borderTop
        mov	ebx, 1
        mov	eax, 4
        int	0x80

        mov     cx, 0
        jmp     cellValues

cellValues:
        push    cx
        mov	edx, 2
        mov	ecx, borderMiddleA
        mov	ebx, 1
        mov	eax, 4
        int	0x80

        mov	edx, 1
        pop     bx
        mov     ecx, [field + bx]
        push    bx
        mov	ebx, 1
        mov	eax, 4
        int	0x80

        mov	edx, 3
        mov	ecx, borderMiddleB
        mov	ebx, 1
        mov	eax, 4
        int	0x80

        pop     cx
        inc     cx
        cmp     cx, 3
        jne     cellValues

        mov	edx, lenBB
        mov	ecx, borderBottom
        mov	ebx, 1
        mov	eax, 4
        int	0x80

        mov     eax, 1   
        int	0x80

section .data
        field db 'X', 'A', 'V', 'A', 'V', 'A', 'V', 0xa

        borderTop db '***** ***** *****', 0dh, 0ah, '*   * *   * *   *', 0xa
        lenBT equ $ - borderTop
        
        borderMiddleA db '* '
        borderMiddleB db ' * '

        borderBottom db 0dh, 0ah, '*   * *   * *   *', 0dh, 0ah, '***** ***** *****', 0xa
        lenBB equ $ - borderBottom

But there was a problem, with this code it throws an error
main.o: в функции «cellValues»:
main.asm:(.text+0x3e): перемещение обрезано по месту: R_386_16 у неопределённого символа «.data»

If you change line 24 in the loop:
mov ecx, [field + bx]
To:
mov ecx, field
Everything works fine.
For assembly I use:
nasm -f elf32 main.asm ld -m elf_i386
-s -o main main.o
forums found only that this error is more common with 16-bit programs, although I write (at least it seems to me) under 32, I will be grateful for your help

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question