English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 19 May 2009, 16:08   #1
Anding
Users Awaiting Email Confirmation
 
Join Date: Nov 2008
Location: Hong Kong
Posts: 56
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  
Old 19 May 2009, 16:12   #2
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
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, 16:40   #3
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
@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, 16:44   #4
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
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 16:54.
StingRay is offline  
Old 19 May 2009, 16:44   #5
Anding
Users Awaiting Email Confirmation
 
Join Date: Nov 2008
Location: Hong Kong
Posts: 56
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, 16:51   #6
Anding
Users Awaiting Email Confirmation
 
Join Date: Nov 2008
Location: Hong Kong
Posts: 56
@ 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, 16:52   #7
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
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, 17:00   #8
Anding
Users Awaiting Email Confirmation
 
Join Date: Nov 2008
Location: Hong Kong
Posts: 56
StingRay, thomas,

Thank you both for such speedy help!
Anding is offline  
Old 20 May 2009, 17:22   #9
redblade
Zone Friend
 
redblade's Avatar
 
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,127
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  
 


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 15:13
C to assembler Jherek Carnelia Coders. General 5 23 July 2011 20:22
Help with Assembler redblade Coders. General 8 23 April 2010 16:00
Assembler for AmigaOS? oRBIT Coders. General 40 03 July 2009 13:54
assembler harlequin request.Apps 26 07 February 2002 20: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 21:20.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10090 seconds with 15 queries