Question

I got an asm macro that can't be found:

puttime_asm.s:5: Error: can't open mymacro.s for reading: No such file or directory
puttime_asm.s:8: Error: unrecognized instruction push
puttime_asm.s:10: Error: unrecognized instruction push
puttime_asm.s:14: Error: unrecognized instruction pop
puttime_asm.s:17: Error: unrecognized instruction push
puttime_asm.s:22: Error: unrecognized instruction pop
puttime_asm.s:24: Error: unrecognized instruction push
puttime_asm.s:34: Error: unrecognized instruction pop
puttime_asm.s:35: Error: unrecognized instruction push
puttime_asm.s:42: Error: unrecognized instruction pop
puttime_asm.s:48: Error: unrecognized instruction pop
make: *** [obj/default/puttime_asm.o] Error 1

**** Build Finished ****

It used to work, then I formatted harddrive and now I'm recovering the project and got build problems. I used Nios II SDK in Quartus II web edition and compiling this used to work. What am I doing wrong?

Thw macro is

.macro PUSH reg
        subi    sp, sp, 4
        stw     \reg, 0(sp)
.endm

.macro POP reg
        ldw     \reg, 0(sp)
        addi    sp, sp, 4
.endm

The file that can't find the macro is

.global puttime

        .text
        .align 2
        .include "mymacro.s"

puttime:
        PUSH r31
        ldw r8,0(r4)            # put the variable in register 8
        PUSH r8
        movi r4, 0x0A           # put newline char in register 4
        movia   r9,putchar      # copy subroutine address to a register
        callr   r9              # call subroutine via register
        POP r8
        srai r7, r8, 12
        mov r4, r7
        PUSH r8
        call hexasc
        mov r4, r2
        movia   r9,putchar      # copy subroutine address to a register
        callr   r9
        POP r8
        mov r6, r8
        PUSH r6
        srai r7, r8, 8
        mov r4, r7
        call hexasc
        mov r4, r2
        movia   r9,putchar      # copy subroutine address to a register
        callr   r9
        movi r4, 0x3A
        movia r9, putchar
        callr r9
        POP r6
        PUSH r6
        srai r7, r6, 4
        mov r4, r7
        call hexasc
        mov r4, r2
        movia   r9,putchar      # copy subroutine address to a register
        callr   r9
        POP r6
        mov r4, r6
        call hexasc
        mov r4, r2
        movia   r9,putchar      # copy subroutine address to a register
        callr   r9
        POP r31
        ret

The file is actually there:

C:\Users\student\Desktop\KTH\Datorteknik\software\nios32io>dir
 Volume in drive C has no label.
 Volume Serial Number is F616-B8C8

 Directory of C:\Users\student\Desktop\KTH\Datorteknik\software\nios32io

2013-07-24  08:17    <DIR>          .
2013-07-24  08:17    <DIR>          ..
2013-07-24  04:33            36 223 .cproject
2013-07-24  04:33             3 002 .project
2012-09-19  15:59               820 checktimer_asm.s
2012-11-16  12:11               481 check_key3.s
2012-11-04  15:22             1 121 get_toggles.s
2012-11-04  15:04               306 hex7seg.c
2012-09-11  07:06               362 hexasc.s
2012-11-06  18:10             1 590 initfix_int.c
2012-11-16  11:43               891 init_timer_asm.s
2013-07-24  04:37            35 759 Makefile
2012-09-11  07:09               139 mymacro.s
2012-11-16  12:05             2 367 putdiff.c
2012-11-10  16:30             1 315 puttime_asm.s
2012-11-08  17:44               515 puttime_hex.c
2012-11-10  16:36               121 put_hexlow.s
2012-11-04  15:06             3 109 put_hexsim.c
2012-11-14  17:19               415 snaptime.s
2012-09-11  07:10             1 207 tick.c
              18 File(s)         89 743 bytes
               2 Dir(s)  63 411 585 024 bytes free

C:\Users\student\Desktop\KTH\Datorteknik\software\nios32io>

Update

I tried all combinations to do this seemingly simple thing. I even tried .include "..\..\..\nios32\mymacro.s" and it's not working. Doing something simple should not be impossible. You're saying this is straightforward, so what is the solution I'm asking for? I'm not asking whether this is easy, I know it's supposed to be easy but since the design sucks doing the easy has become impossible.

enter image description here

Was it helpful?

Solution

It's working now. It was a somewhat complicated FPGa project that might have lacked some necessary files. This way to include is working:

.global puttime

        .text
        .align 2
        .include "mymacro.s"

puttime:
        PUSH r31
        ldw r8,0(r4)            # put the variable in register 8
        #mov r15, r8
        #PUSH r15
        PUSH r8
        movi r4, 0x0A           # put newline char in register 4
        movia   r9,putchar      # copy subroutine address to a register
        PUSH r4
        callr   r9              # call subroutine via register
        POP r4
        movia r9, lcdput
        callr r9
        POP r8
        srai r7, r8, 12
        mov r4, r7
        PUSH r8
        call hexasc
        mov r4, r2
        movia   r9,putchar      # copy subroutine address to a register
        PUSH r4
        callr   r9
        POP r4
        movia r9, lcdput
        callr r9
        POP r8
        mov r6, r8
        PUSH r6
        srai r7, r8, 8
        mov r4, r7
        call hexasc
        mov r4, r2
        movia   r9,putchar      # copy subroutine address to a register
        PUSH r4
        callr   r9
        POP r4
        movia r9, lcdput
        callr r9
        movi r4, 0x3A
        movia r9, putchar
        PUSH r4
        callr r9
        POP r4
        movia r9, lcdput
        callr r9
        POP r6
        PUSH r6
        srai r7, r6, 4
        mov r4, r7
        call hexasc
        mov r4, r2
        movia   r9,putchar      # copy subroutine address to a register
        PUSH r4
        callr   r9
        POP r4
        movia r9, lcdput
        callr r9
        POP r6
        mov r4, r6
        call hexasc
        mov r4, r2
        movia   r9,putchar      # copy subroutine address to a register
        PUSH r4
        callr   r9
        POP r4
        movia r9, lcdput
        callr r9
        POP r31
        ret

The code runs on the FPGA and creates a clock:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top