Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Calling C from sound handler crashes system

View Parsed - Show only message text

Path: g2news1.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!solnet.ch!solnet.ch!news.clara.net!wagner.news.clara.net!195.245.201.10.MISMATCH!monkeydust.news.clara.net!damia.uk.clara.net
From: Jonathan Duddingon <nos...@jsd.clara.co.uk>
Subject: Calling C from sound handler crashes system
Newsgroups: comp.sys.acorn.programmer
Date: Sat, 01 Apr 2006 00:27:46 +0100
Message-ID: <4e10767094nospam@jsd.clara.co.uk>
User-Agent: Pluto/3.04c (RISC-OS/4.02) NewsHound/1.42
Organization: None
X-Complaints-To: abuse@clara.net (please include full headers)
X-Trace: 0fe3200a23321033e4593e6c862033861335623e120a44882ae03033442dbb7e
NNTP-Posting-Date: Sat, 01 Apr 2006 00:30:06 +0100
Lines: 71

The Speak text-to-speech module processes text into phonemes and then
into a lower level form of formants (peaks in the frequency spectrum)
which are then queued for output (the "wcmdq")

Speak registers a RISC_OS "Linear Sound Handler" (SWI &40145) which
runs as an interrupt (IRQ mode? I'm not sure of the correct
terminology) whenever the sound DMA needs filling.  Speak's sound
handler takes items from this wcmdq and converts them to the sound
waveform to put into the sound DMA.

When the wcmdq gets low, the sound handler sets a transient callback
(SWI &54) to ask the OS to run the user mode part of the module to
convert some more text->phonemes->wcmdq.

This all works properly in the currently available Speak version 2,
where the sound handler is written entirely in assembler.

I'm now trying to port a re-write which I did on Linux
(espeak.sourceforge.net) to RISC_OS.  I don't want to write the sound
waveform generation code in assembler, so the only assembler code is a
few lines of the sound handler which calls a C function and then sets
the callback if needed.

But calling the C function from the sound handler gives:
   not enough memory - stack overflow
   filecore in use
(which of course means the system then needs a restart).

The callback-setting is commented out, so that's not the problem.

Calling a dummy C function (one which just assigns a couple of
variables) is OK.  No error.

Calling a dummy C function which then calls another dummy C function
gives the error and doesn't return.

I've checked the ARM procedure calling protocols and I think that's OK.
The test code is:

 IMPORT DummyProc1

 DMA_Handler
 ;**********
 ; linear sound handler, fill the sound DMA
 ; preserve r11,r12,r13 (fp,ip,sp)
 ; r1,r2 start and end of DMA buffer

	MOV	r5,ip		; need to save ip
	MOV	ip,sp		;set up a stack
	STMFD	sp!, {fp,ip,lr,pc}

	MOV	r6,r1		;DMA start  16 bit sound
	MOV	r7,r2		;DMA end

	SUB	r0,r7,r6        ;r0 = size of DMA buffer
 BL  DummyProc1      ; which then calls DuumyProc2

 NOP
 MOV ip,r5
	LDMFD	sp, {fp,sp,pc}   ; procedure exit from Sound Handler

When the error occurs, the NOP isn't reached (i.e. DummyProc1 doesn't
return).

Am I doing something wrong, or is it just not possible to call a chain
of C functions from assembler in general, or from a sound handler in
particular?

-- 
  change nospam in the reply email address to "jsd"
  

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google