3

我有一个找不到的 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" ,但它不起作用。做一些简单的事情不应该是不可能的。你说这很简单,那么我要的解决方案是什么?我不是在问这是否容易,我知道这应该很容易,但由于设计很糟糕,所以简单已经成为不可能。

在此处输入图像描述

4

1 回答 1

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 上运行并创建一个时钟:

在此处输入图像描述

于 2013-07-30T05:45:45.310 回答