1988-06-22 16:57:09 +00:00
|
|
|
/*
|
|
|
|
* Sources of the "BRANCH" group instructions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Header$ */
|
|
|
|
|
|
|
|
#include <em_abs.h>
|
|
|
|
#include "global.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "mem.h"
|
|
|
|
#include "trap.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "fra.h"
|
|
|
|
#include "warn.h"
|
|
|
|
|
|
|
|
/* Note that in the EM assembly language brach instructions have
|
|
|
|
lables as their arguments, where in the EM machine language they
|
|
|
|
have (relative) offsets as parameters. This is not described in the
|
|
|
|
EM manual but follows from the Pascal interpreter.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define do_jump(j) { newPC(PC + (j)); }
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoBRA(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* BRA b: Branch unconditionally to label b */
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoBRA(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoBLT(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* BLT b: Branch less (pop 2 words, branch if top > second) */
|
|
|
|
register long t = wpop();
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoBLT(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (wpop() < t)
|
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoBLE(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* BLE b: Branch less or equal */
|
|
|
|
register long t = wpop();
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoBLE(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (wpop() <= t)
|
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoBEQ(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* BEQ b: Branch equal */
|
|
|
|
register long t = wpop();
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoBEQ(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (t == wpop())
|
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoBNE(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* BNE b: Branch not equal */
|
|
|
|
register long t = wpop();
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoBNE(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (t != wpop())
|
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoBGE(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* BGE b: Branch greater or equal */
|
|
|
|
register long t = wpop();
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoBGE(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (wpop() >= t)
|
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoBGT(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* BGT b: Branch greater */
|
|
|
|
register long t = wpop();
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoBGT(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (wpop() > t)
|
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoZLT(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* ZLT b: Branch less than zero (pop 1 word, branch negative) */
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoZLT(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (wpop() < 0)
|
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoZLE(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* ZLE b: Branch less or equal to zero */
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoZLE(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (wpop() <= 0)
|
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoZEQ(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* ZEQ b: Branch equal zero */
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoZEQ(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (wpop() == 0)
|
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoZNE(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* ZNE b: Branch not zero */
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoZNE(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (wpop() != 0)
|
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoZGE(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* ZGE b: Branch greater or equal zero */
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoZGE(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (wpop() >= 0)
|
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoZGT(jump)
|
|
|
|
register long jump;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* ZGT b: Branch greater than zero */
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@B6 DoZGT(%ld)", jump));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (wpop() > 0)
|
|
|
|
do_jump(arg_c(jump));
|
|
|
|
}
|