Getting started in assembly

Moderators: None (Apply to moderate this forum)
Number of threads: 219
Number of posts: 577

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
problem including assembly/c header file [i think] Posted by cdavids on 14 Sept 2006 at 10:17 AM
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.

Report
Re: problem including assembly/c header file [i think] Posted by IDK on 16 Sept 2006 at 7:52 AM
: 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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.