如何简单地找到一个宏?

时间:2013-07-24 20:03:06

标签: assembly windows-7 fpga nios

我找到了一个无法找到的asm宏:

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 ****

它曾经工作,然后我格式化硬盘,现在我正在恢复项目并遇到构建问题。我在Quartus II网络版中使用了Nios II SDK并编译了这个以前的工作。我做错了什么?

Thw宏是

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

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

无法找到宏的文件是

.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

文件实际上就在那里:

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>

更新

我尝试了所有组合来做这个看似简单的事情。我甚至试过.include "..\..\..\nios32\mymacro.s" 但它没有用。做一些简单的事不应该是不可能的。你说这很简单,那么我要求的解决方案是什么?我不是在问这是否容易,我知道它应该很容易但是因为设计糟透了,所以不可能。

enter image description here

1 个答案:

答案 0 :(得分:0)

现在正在运作。这是一个有点复杂的FPGa项目,可能缺少一些必要的文件。这种方式包括工作:

.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

代码在FPGA上运行并创建一个时钟:

enter image description here