Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

problem including assembly/c header file [i think]

Hello,

I am trying to use and include an object file with my (gnu 'as') assembly program.

I'm fairly new to the assembly world, did some SPARC years ago in school, but I'm having problems finding the right resources that explain how to include and link object files.

I'm trying to include the file 'asm_io.inc' in test.s by:

// top of test.s

.include "asm_io.inc"

// asm_io.inc:

extern read_int, print_int, print_string
extern read_char, print_char, print_nl
extern sub_dump_regs, sub_dump_mem, sub_dump_math, sub_dump_stack

%macro dump_regs 1
push dword %1
call sub_dump_regs
%endmacro


;
; usage: dump_mem label, start-address, # paragraphs
%macro dump_mem 3
push dword %1
push dword %2
push dword %3
call sub_dump_mem
%endmacro

%macro dump_math 1
push dword %1
call sub_dump_math
%endmacro

%macro dump_stack 3
push dword %3
push dword %2
push dword %1
call sub_dump_stack
%endmacro


Perhaps this is in issues of assembler-specific syntax for header files? I tried to search for solutions, but I am not even that familiar with the terms that I should be searching for!


I get the following errors when I try to assemble (as -o test.o test.s):

asm_io.inc: Assembler messages:
asm_io.inc:1: Error: no such instruction: `extern read_int,print_int,print_string'
asm_io.inc:2: Error: no such instruction: `extern read_char,print_char,print_nl'
asm_io.inc:3: Error: no such instruction: `extern sub_dump_regs,sub_dump_mem,sub_dump_math,sub_dump_stack'


and a bunch of these (one for each %):

asm_io.inc:13: Error: junk at end of line, first unrecognized character is `%'


I can do my best to provide more info if needed; any help would be greatly appreciated! Thank you in advance.

Comments

  • IDKIDK Member Posts: 1,784
    : Hello,
    :
    : I am trying to use and include an object file with my (gnu 'as') assembly program.
    :
    : I'm fairly new to the assembly world, did some SPARC years ago in school, but I'm having problems finding the right resources that explain how to include and link object files.
    :
    : I'm trying to include the file 'asm_io.inc' in test.s by:
    :
    : // top of test.s
    :
    : .include "asm_io.inc"
    :
    : // asm_io.inc:
    :
    : extern read_int, print_int, print_string
    : extern read_char, print_char, print_nl
    : extern sub_dump_regs, sub_dump_mem, sub_dump_math, sub_dump_stack
    :
    : %macro dump_regs 1
    : push dword %1
    : call sub_dump_regs
    : %endmacro
    :
    :
    : ;
    : ; usage: dump_mem label, start-address, # paragraphs
    : %macro dump_mem 3
    : push dword %1
    : push dword %2
    : push dword %3
    : call sub_dump_mem
    : %endmacro
    :
    : %macro dump_math 1
    : push dword %1
    : call sub_dump_math
    : %endmacro
    :
    : %macro dump_stack 3
    : push dword %3
    : push dword %2
    : push dword %1
    : call sub_dump_stack
    : %endmacro
    :
    :
    : Perhaps this is in issues of assembler-specific syntax for header files? I tried to search for solutions, but I am not even that familiar with the terms that I should be searching for!
    :
    :
    : I get the following errors when I try to assemble (as -o test.o test.s):
    :
    : asm_io.inc: Assembler messages:
    : asm_io.inc:1: Error: no such instruction: `extern read_int,print_int,print_string'
    : asm_io.inc:2: Error: no such instruction: `extern read_char,print_char,print_nl'
    : asm_io.inc:3: Error: no such instruction: `extern sub_dump_regs,sub_dump_mem,sub_dump_math,sub_dump_stack'
    :
    :
    : and a bunch of these (one for each %):
    :
    : asm_io.inc:13: Error: junk at end of line, first unrecognized character is `%'
    :
    :
    : I can do my best to provide more info if needed; any help would be greatly appreciated! Thank you in advance.
    :
    :


    If we have file A containing the word "Alfa" and file B looks like:

    include "A"
    Beta

    Then the preproccessor would combine the files and give the compiler this input:

    Alfa
    Beta

    Simply remove the extern thingys

    This is how fasm works, but I have no idea how your compiler works.
Sign In or Register to comment.