ack/util/int/do_branch.c

158 lines
2.7 KiB
C
Raw Permalink Normal View History

2019-03-17 14:42:00 +00:00
/** @file
1988-06-22 16:57:09 +00:00
* Sources of the "BRANCH" group instructions
*/
1994-06-24 11:31:16 +00:00
/* $Id$ */
1988-06-22 16:57:09 +00:00
2019-03-17 14:42:00 +00:00
#include "em_abs.h"
1988-06-22 16:57:09 +00:00
#include "global.h"
#include "log.h"
#include "mem.h"
#include "trap.h"
#include "text.h"
#include "fra.h"
#include "warn.h"
#include "switch.h"
1988-06-22 16:57:09 +00:00
/* 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)); }
2019-03-17 14:42:00 +00:00
void DoBRA(register long jump)
1988-06-22 16:57:09 +00:00
{
/* BRA b: Branch unconditionally to label b */
LOG(("@B6 DoBRA(%ld)", jump));
1988-06-22 16:57:09 +00:00
do_jump(arg_c(jump));
}
2019-03-17 14:42:00 +00:00
void DoBLT(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();
LOG(("@B6 DoBLT(%ld)", jump));
1988-06-22 16:57:09 +00:00
spoilFRA();
if (wpop() < t)
do_jump(arg_c(jump));
}
2019-03-17 14:42:00 +00:00
void DoBLE(register long jump)
1988-06-22 16:57:09 +00:00
{
/* BLE b: Branch less or equal */
register long t = wpop();
LOG(("@B6 DoBLE(%ld)", jump));
1988-06-22 16:57:09 +00:00
spoilFRA();
if (wpop() <= t)
do_jump(arg_c(jump));
}
2019-03-17 14:42:00 +00:00
void DoBEQ(register long jump)
1988-06-22 16:57:09 +00:00
{
/* BEQ b: Branch equal */
register long t = wpop();
LOG(("@B6 DoBEQ(%ld)", jump));
1988-06-22 16:57:09 +00:00
spoilFRA();
if (t == wpop())
do_jump(arg_c(jump));
}
2019-03-17 14:42:00 +00:00
void DoBNE(register long jump)
1988-06-22 16:57:09 +00:00
{
/* BNE b: Branch not equal */
register long t = wpop();
LOG(("@B6 DoBNE(%ld)", jump));
1988-06-22 16:57:09 +00:00
spoilFRA();
if (t != wpop())
do_jump(arg_c(jump));
}
2019-03-17 14:42:00 +00:00
void DoBGE(register long jump)
1988-06-22 16:57:09 +00:00
{
/* BGE b: Branch greater or equal */
register long t = wpop();
LOG(("@B6 DoBGE(%ld)", jump));
1988-06-22 16:57:09 +00:00
spoilFRA();
if (wpop() >= t)
do_jump(arg_c(jump));
}
2019-03-17 14:42:00 +00:00
void DoBGT(register long jump)
1988-06-22 16:57:09 +00:00
{
/* BGT b: Branch greater */
register long t = wpop();
LOG(("@B6 DoBGT(%ld)", jump));
1988-06-22 16:57:09 +00:00
spoilFRA();
if (wpop() > t)
do_jump(arg_c(jump));
}
2019-03-17 14:42:00 +00:00
void DoZLT(register long jump)
1988-06-22 16:57:09 +00:00
{
/* ZLT b: Branch less than zero (pop 1 word, branch negative) */
LOG(("@B6 DoZLT(%ld)", jump));
1988-06-22 16:57:09 +00:00
spoilFRA();
if (wpop() < 0)
do_jump(arg_c(jump));
}
2019-03-17 14:42:00 +00:00
void DoZLE(register long jump)
1988-06-22 16:57:09 +00:00
{
/* ZLE b: Branch less or equal to zero */
LOG(("@B6 DoZLE(%ld)", jump));
1988-06-22 16:57:09 +00:00
spoilFRA();
if (wpop() <= 0)
do_jump(arg_c(jump));
}
2019-03-17 14:42:00 +00:00
void DoZEQ(register long jump)
1988-06-22 16:57:09 +00:00
{
/* ZEQ b: Branch equal zero */
LOG(("@B6 DoZEQ(%ld)", jump));
1988-06-22 16:57:09 +00:00
spoilFRA();
if (wpop() == 0)
do_jump(arg_c(jump));
}
2019-03-17 14:42:00 +00:00
void DoZNE(register long jump)
1988-06-22 16:57:09 +00:00
{
/* ZNE b: Branch not zero */
LOG(("@B6 DoZNE(%ld)", jump));
1988-06-22 16:57:09 +00:00
spoilFRA();
if (wpop() != 0)
do_jump(arg_c(jump));
}
2019-03-17 14:42:00 +00:00
void DoZGE(register long jump)
1988-06-22 16:57:09 +00:00
{
/* ZGE b: Branch greater or equal zero */
LOG(("@B6 DoZGE(%ld)", jump));
1988-06-22 16:57:09 +00:00
spoilFRA();
if (wpop() >= 0)
do_jump(arg_c(jump));
}
2019-03-17 14:42:00 +00:00
void DoZGT(register long jump)
1988-06-22 16:57:09 +00:00
{
/* ZGT b: Branch greater than zero */
LOG(("@B6 DoZGT(%ld)", jump));
1988-06-22 16:57:09 +00:00
spoilFRA();
if (wpop() > 0)
do_jump(arg_c(jump));
}