English Amiga Board   Amiga Lore


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 19 May 2009, 17:08   #1
Anding
Registered User
 
Join Date: Nov 2008
Location: Hong Kong
Posts: 55
Question SIGBREAK_CTRL_C from assembler?

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


Code:
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
Anding is offline  
AdSense AdSense  
Old 19 May 2009, 17:12   #2
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,111
Code:
	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
StingRay is offline  
Old 19 May 2009, 17:40   #3
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 4,656
@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.
thomas is offline  
Old 19 May 2009, 17:44   #4
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,111
Quote:
Originally Posted by thomas View Post
@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?

Last edited by StingRay; 19 May 2009 at 17:54.
StingRay is offline  
Old 19 May 2009, 17:44   #5
Anding
Registered User
 
Join Date: Nov 2008
Location: Hong Kong
Posts: 55
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 is offline  
Old 19 May 2009, 17:51   #6
Anding
Registered User
 
Join Date: Nov 2008
Location: Hong Kong
Posts: 55
@ 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

Code:
   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
Anding is offline  
Old 19 May 2009, 17:52   #7
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 4,656
This code works when compiled with DCC's or VBCC's builtin assembler (it's the entire program, not only a snippet):

Code:
	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.
thomas is offline  
Old 19 May 2009, 18:00   #8
Anding
Registered User
 
Join Date: Nov 2008
Location: Hong Kong
Posts: 55
StingRay, thomas,

Thank you both for such speedy help!
Anding is offline  
Old 20 May 2009, 18:22   #9
redblade
Zone Friend

redblade's Avatar
 
Join Date: Mar 2004
Location: Norge
Age: 30
Posts: 971
stingray: do you use dos.library/CheckSignal() in a loop? Just wondering for future shitty DOS programs.

Or do I call a GetMsg()?
redblade is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Which assembler to use BanisterDK Coders. General 4 10 January 2012 16:13
C to assembler Jherek Carnelia Coders. General 5 23 July 2011 21:22
Help with Assembler redblade Coders. General 8 23 April 2010 17:00
Assembler for AmigaOS? oRBIT Coders. General 40 03 July 2009 14:54
assembler harlequin request.Apps 26 07 February 2002 21:53

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:31.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Page generated in 0.13383 seconds with 11 queries