EASy68K
http://www.easy68k.com/EASy68Kforum/

Calling Macro twice freezes program?
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1605
Page 1 of 1

Author:  ZoaolTD [ Thu Nov 23, 2017 6:27 pm ]
Post subject:  Calling Macro twice freezes program?

Forgive me if this is a silly question, but I'm not too sure why this code doesn't work.
Basically, I want to have a small time delay at the start of my code, then after the user presses Enter or Space, have another time delay before moving onto another section of code. The problem is that the first delay call works correctly, but when the second is called it just completely freezes the program. If I trace into the code or pause and unpause when it is frozen it will continue on with the code correctly, but running it normally will just completely freeze it.

The code in question is below.

Code:
    ORG    $1000
   
DELAY    MACRO
    MOVE    #23,            D0     
    MOVE    #\1,            D1     
    TRAP    #15                 
    ENDM
   
START:                 
    DELAY    10
    LEA     INPUT,          A1     
    MOVE.B  #14,            D0
    TRAP    #15                 
    repeat
        MOVE.L  #$0D200000, D1
        MOVE.B  #19,        D0
        TRAP    #15           
    until.l D1 <ne> #0 do       
    MOVE.B  #11,        D0     
    MOVE.W  #$FF00,     D1
    TRAP    #15
   DELAY    10
    LEA     OUTPUT,         A1     
    MOVE.B  #14,            D0
    TRAP    #15                 
    SIMHALT             

INPUT    DC.B    'Press Enter or Space.',0   
OUTPUT   DC.B    'Done.',0

    END    START       

Author:  profkelly [ Thu Nov 23, 2017 7:38 pm ]
Post subject:  Re: Calling Macro twice freezes program?

When DELAY 10 is called the second time register D1.L contains data in the upper word that is not being cleared by the macro. This results in a very long delay time (The delay traps task uses all 32 bits of D1 as the delay value.)

Change the DELAY macro to store 32 bit data to D1.
Code:
DELAY    MACRO
    MOVE    #23,            D0     
    MOVE.L  #\1,            D1     
    TRAP    #15                 
    ENDM

Author:  ZoaolTD [ Thu Nov 23, 2017 7:56 pm ]
Post subject:  Re: Calling Macro twice freezes program?

Works perfectly, thank you very much!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/