代码之家  ›  专栏  ›  技术社区  ›  The Tokenizer

在程序集代码中查找错误时出错

  •  -1
  • The Tokenizer  · 技术社区  · 14 年前

    说到汇编语言,我是个初学者。我使用“easy 68k编辑器/汇编程序”编写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
    
    2 回复  |  直到 14 年前
        1
  •  1
  •   TMN    14 年前

    您的代码应该以以下内容开头:

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

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

        2
  •  0
  •   Durandal    14 年前

    你使用的陷阱很可能不是Easy68K使用的陷阱。看 here Easy68K使用的陷阱。

    陷阱指令的功能是 不 由68K汇编语言定义,但由操作系统分配(如果操作系统使用了陷阱,有些人会忽略它们)。如果你执行一个陷阱指令,68000只执行陷阱向量指向的代码。没有“内置”函数分配给任何陷阱。

    推荐文章