【问题标题】:Having trouble finding error in my assembly code在我的汇编代码中找不到错误
【发布时间】:2012-07-15 16:56:58
【问题描述】:

我是汇编语言的初学者。我正在使用“easy 68k editor/assembler”编写 68k 汇编代码,该代码要求用户输入 2 个值,然后将它们汇总在一起并显示出来。问题是我的代码不断停止,我不知道如何解决/调试这个问题。

谁能帮我弄清楚如何追踪错误?我会很感激。提前谢谢你。

*-----------------------------------------------------------
* Program    : Sum of Two Numbers
* Written by : Me
* Date       : July 15, 2012
* Description: This program will read in 2 numbers the user
*inputs and find the sum.
*-----------------------------------------------------------

    org     $8000

    START       movea.l #MSG1, A3
                trap    #3
                clr.w   D2
                JSR     Loop
                trap    #2
                move.w  d2, d4
                movea.l #msg2, a3
                trap    #3
                clr.w   d2
                jsr     loop
                trap    #2
                movea.l #msg3, A3
                trap    #3
                add.w   d4, d2
                JSR     DISP
                trap    #2
                trap    #9
    LOOP        trap    #0
                trap    #1
                cmp.b   #$0D, D1
                BEQ     BREAK
                and.b   #$0F, d1
                mulu    #10, d2
                add.w   d1, d2
                jmp     loop
    Break       rts
    DISP        clr.b   d3
    DISDIV      divu    #10, D2
                move.b  #16, d5
                ror.l   d5, d2
                or.b    #$30, d2
                move.b  d2, -(A7)
                addq    #1, d3
                clr.w   d2
                ror.l   d5, d2
                bne     DISDIV
    DISDIG      move.b  (a7)+, D1
                trap    #1
                subq.b  #1, D3
                bne     DISDIG
                rts
                org     $8100
    MSG1        DC.B    'Please enter the first of two numbers (two digits) ', 0
    MSG2        DC.B    'Please enter the second of two numbers (two digits) ', 0
    MSG3        DC.B    'The sum of the two 2 digit numbers you entered is ', 0
                end     start

【问题讨论】:

  • 如果有其他论坛我可以更好地发布此内容,请告诉我。谢谢
  • 不能在 68000 模拟器中单步执行,看看哪里出错了?
  • 我知道失败的地方。我只是不知道为什么。它是一个陷阱异常,我称之为我的第一个陷阱#3。
  • 如果你知道它失败的地方,为什么不在问题中这么说呢?您提供的信息越多,别人就越有可能提供帮助。
  • trap #3 应该做什么?它的参数是什么?更好的是,发布代码正在使用的 API 的链接,以便我们弄清楚。

标签: debugging assembly compiler-construction machine-code 68000


【解决方案1】:

您的代码应以:

LEA    MSG1, A1
MOVE.B #14, D0
TRAP   #15

这将向用户显示第一条消息。查看EASy68K home page 了解有关调用 I/O 陷阱的更多信息。

【讨论】:

    【解决方案2】:

    您使用的陷阱很可能不是 Easy68K 使用的陷阱。查看here 了解Easy68K 使用的陷阱。

    陷阱指令的功能不是由 68K 汇编语言定义,而是由操作系统分配(如果操作系统完全使用陷阱,有些会忽略它们)。如果您执行陷阱指令,68000 只会执行陷阱向量指向的代码。没有为任何陷阱分配“内置”功能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多