4

Can anyone post some source code that, when compiled (if necessary) and run, will produce a 'Guru Meditation Error' on an Amiga.

Assembler, C or ARexx will do.

Thanks.

Steve Ives
  • 7,894
  • 3
  • 24
  • 55

3 Answers3

9

Try the Alert() function of the exec.library: http://amigadev.elowar.com/read/ADCD_2.1/Includes_and_Autodocs_3._guide/node01E3.html

For instance (in C):

#include <exec/execbase.h>
#include <exec/alerts.h>

#include <clib/exec_protos.h>

void main(void) {
    Alert(ACPU_InstErr); /* or use 0x80000004 if you don't have alerts.h */

    /* might not return if it was a dead end (non-recoverable) alert */
}
blubberdiblub
  • 4,085
  • 1
  • 28
  • 30
2

A good old division by zero can do the job.

#include <stdio.h>
void main() {
  printf("%d", 1/0);
};
FredericK
  • 1,612
  • 1
  • 18
  • 26
  • Thanks Guys - this was in response to something on 'Code Golf' about generation weird/amusing errors. I thought a 'Guru Meditation' would count... – Steve Ives Mar 17 '16 at 15:28
  • 2
    This isn't the most direct way to invoke a Guru, and a recent compiler might be reluctant with the explicit division by zero :) – Astrofra Aug 20 '22 at 07:22
1

I'm not sure the divide by zero method is the most direct one to invoke a Guru Mediation. I tried on the actual AmigaOS3.1 and the divide by zero error is caught by the OS before it ends up in the Guru we love :)

enter image description here

To be honest, I was even surprised that SAS/C would accept to compile this code. GCC is less tolerant:

astrofra@ubuntu: ~$ gcc main.c
main.c:3:17: warning: division by zero [-Wdiv-by-zero]
   printf("%d", 1/0);

The AmigaOS Alert() function is indeed recommended. I used it extensively at debugging stage when working on Athanor 2.

Astrofra
  • 321
  • 4
  • 12