Skip to contentSkip to conversation

simple assembler program

DISCUSSION Roman Mashak 3 participants 3 messages Jul 21, 2004 MIPS

lore
Share & tools
lore
#0 lore raw

Hello!

I tried to compile simple assembler program:

#define a 1
#define b 2

.ent main
.global main
main:

        li $3, a
        li $2, b
        addu $4, $2, $3

.end main

I use SDE-lite kit version 5.03.06 and compile with sde-as:
#sde-as test.S -o testtest.S: Assembler messages:
test.S:9: Error: absolute expression required li' test.S:10: Error: absolute expression required li'

When I eliminate #define and use just 'li $3, 1' and so on - everything is compiled correctly. Where is my problem?

Thanks in advance!

With best regards, Roman Mashak. E-mail: [email protected]

#1 lore raw

On Wed, 2004-07-21 14:17:14 +0900, Roman Mashak <[email protected]> wrote in message <002701c46ee1$feeb7fc0$cc20bdd3@roman>:

Quoted 11 lines

#define a 1
#define b 2

.ent main
.global main
main:

        li $3, a
        li $2, b
        addu $4, $2, $3

.end main

Quoted 7 lines

I use SDE-lite kit version 5.03.06 and compile with sde-as:
#sde-as test.S -o testtest.S: Assembler messages:
test.S:9: Error: absolute expression required li' test.S:10: Error: absolute expression required li'

When I eliminate #define and use just 'li $3, 1' and so on - everything is compiled correctly. Where is my problem?

Assembler sources aren't commonly fed through a preprocessor, so your assembler just ignores the comments (your defines) and uses "a" and "b" as-is.

MfG, JBG

Signature · 4 lines
   Jan-Benedict Glaw       [email protected]    . +49-172-7608481
   "Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg
    fuer einen Freien Staat voll Freier Bürger" | im Internet! |   im Irak!
   ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
#2 lore raw
Quoted 10 lines · Jan-Benedict Glaw
Quoted 6 lines

#sde-as test.S -o testtest.S: Assembler messages:
test.S:9: Error: absolute expression required li' test.S:10: Error: absolute expression required li'

When I eliminate #define and use just 'li $3, 1' and so on - everything is compiled correctly. Where is my problem?

Assembler sources aren't commonly fed through a preprocessor, so your assembler just ignores the comments (your defines) and uses "a" and "b" as-is.

However, they would be, based on the file name suffix, which is .S for
assembly to be preprocessed or .s for one not to, if fed to the assembler via the gcc driver.

Maciej