PDA

View Full Version : SIGBREAK_CTRL_C from assembler?


Anding
19 May 2009, 16:08
I'm trying to write a small routine that waits until CTRL-C is pressed. The program is run from the CLI on WB1.3 (AmigaForever A500). For some reason the following just locks up the machine at the same time as making the screen flicker madly... Any ideas on how to do this right?

Many thanks in advance



SIGBREAKF_CTRL_C equ $1000

move.l 4,a6 ; system base
move.l #SIGBREAKF_CTRL_C,d0 ; signal on CTRL-C
jsr _LVOWait(a6) ; wait for this signal

StingRay
19 May 2009, 16:12
move.l #1<<12,d1 ; SIGBREAKF_CTRL_C
move.l DOSbase(a5),a6
jsr _LVOCheckSignal(a6)
tst.l d0
beq.b .nobreak
; break signal received here.
nop

.nobreak
rts

thomas
19 May 2009, 16:40
@Anding:

Your code is correct, except that it is missing an RTS at the end and _LVOWait is not definined. I assume that this is only an extract of the entire program and your mistake is elsewhere, not shown here.


@StingRay:

Your code does not wait for the signal. It returns immediately.

StingRay
19 May 2009, 16:44
@StingRay:

Your code does not wait for the signal. It returns immediately.

If that would be true the tool I'm using this code in wouldn't quit once I press CTRL+C. It has to be called in loop obviously though as it just returns if CTRL+C has been pressed or not.

Edit: I got your point now Thomas and what you said is of course true. ;)

Anding: Your code should work work fine, can it be you maybe just forget the rts as Thomas already guessed?

Anding
19 May 2009, 16:44
Thanks Stingray. What I am trying to do though is put my task to sleep until it is killed with CTRL-C. If possible I would like to avoid a busy loop, hence my hopes with _LVOWait? (The reason for this by the way is that I'm experimenting with some simple display code and wanted a quick way to just hold the screen until I'm ready to quit out).

Anding
19 May 2009, 16:51
@ Thomas,

Yes I include to define _LVOWait, and have an RTS in the following section. I assume I must have a problem elsewhere in my program that sets this up to fail. When I run a simple executable with this code alone, it works


include exec/exec_lib.i
; equates
SIGBREAKF_CTRL_C equ $1000


; code
section CODE_C ; chipram for custom chip DMA access


; wait for a signal
move.l 4,a6 ; system base
move.l #SIGBREAKF_CTRL_C,d0 ; signal on CTRL-C
jsr _LVOWait(a6) ; wait for this signal

; exit
moveq #0,d0
rts

thomas
19 May 2009, 16:52
This code works when compiled with DCC's or VBCC's builtin assembler (it's the entire program, not only a snippet):


section code,code

SIGBREAKF_CTRL_C equ $1000
_LVOWait equ -318

move.l 4,a6 ; system base
move.l #SIGBREAKF_CTRL_C,d0 ; signal on CTRL-C
jsr _LVOWait(a6) ; wait

rts


So the code is correct. The mistake is elsewhere.

Anding
19 May 2009, 17:00
StingRay, thomas,

Thank you both for such speedy help! :)

redblade
20 May 2009, 17:22
stingray: do you use dos.library/CheckSignal() in a loop? Just wondering for future shitty DOS programs.

Or do I call a GetMsg()?