S
S
sddvxd2019-04-16 12:54:06
C++ / C#
sddvxd, 2019-04-16 12:54:06

How to connect an assembler program with a C program?

There is a Linux program that contains a function to print a single letter to the console:

global test

section .data
msg db 0xD0, 0xBF, 10
msg_len equ $-msg

section .text
test:   push ebp
        mov ebp, esp

        mov eax, 4
        mov ebx, 1
        mov ecx, msg
        mov edx, msg_len
        int 80h

        mov eax, 1
        mov ebx, 0
        int 80h

        mov esp, ebp
        pop ebp
        ret

And the C program that tries to call the test subroutine:
extern void test();

int main(){
        test();
}

There are 2 object files that I try to link into an executable:
gcc main.o file.o -m32
Response:
main.o: In function main':
main.cpp:(.text+0x1b): undefined reference totest()'
Please tell me how to do it right to get an executable file

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
sddvxd, 2019-04-16
@sddvxd

Problem solved - I compiled the code not in C, but in C ++ and the linker could not find the symbol. The problem was solved by adding extern "C" to the C++ code

U
ukoHka, 2017-02-24
@patrickj

If you fix the height of the blocks, then you can do this:
https://jsfiddle.net/4nz26es8/

D
Dmitry, 2017-02-24
@soledar10

https://jsfiddle.net/soledar10/cyagysc9/

Y
Yaroslav Ivanov, 2017-02-24
@space2pacman

https://jsfiddle.net/space2pacman/rnsughc1/6/

V
Vitaliy Orlov, 2017-02-24
@orlov0562

div.btn {
  position: relative;
  top: -50px; 
  left: calc( 50% - 50px );
  width: 100px; 
  height: 100px;
  border-radius: 50px; 
  background-color:red;
}

this is how it is clear how the elements are arranged
https://jsfiddle.net/0sfugdzm/
and this will be a single background:
https://jsfiddle.net/0sfugdzm/1/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question