R-20 Simulator
 Alle Dateien Funktionen Variablen Makrodefinitionen
core.c-Dateireferenz
#include <assert.h>
#include "core.h"

Funktionen

void copy_reg (char *dst, char *src)
 Copy contents of src to dst, whose contents will be lost.
int get_e (char *r)
 Return exponent of register.
void inc_e (char *r)
 Increase exponent by 1.
void shiftr1 (char *r)
 Shift mantissa 1 digit to the right.
void shiftr (char *r, int n)
 Shift mantissa n digits to the right.
void plus (char *res, char *r1, char *r2)
 Add two registers and store result in third one.
void pop ()
 Deletes top of stack.
void push (char *r)
 Put argument into X register and shifts the stack.
void enter ()
 Perform stack function "enter".
void init_core ()

Variablen

char reg [REG_NR][NUMBER_SIZE]
 Memory locations for virtual X, Y, Z, T, A, B registers.
char flags
 Holds flags (INFTY, DIV0...).

Dokumentation der Funktionen

void copy_reg ( char *  dst,
char *  src 
)

Copy contents of src to dst, whose contents will be lost.

void enter ( )

Perform stack function "enter".

int get_e ( char *  r)

Return exponent of register.

void inc_e ( char *  r)

Increase exponent by 1.

void init_core ( )
void plus ( char *  res,
char *  r1,
char *  r2 
)

Add two registers and store result in third one.

res <– r1 + r2. Even in case of overflow, res is changed in the process.

void pop ( )

Deletes top of stack.

void push ( char *  r)

Put argument into X register and shifts the stack.

Argument should be one of reg[A] or reg[B].

void shiftr ( char *  r,
int  n 
)

Shift mantissa n digits to the right.

void shiftr1 ( char *  r)

Shift mantissa 1 digit to the right.

Last digit is lost, but correct rounding on second-to-last digit is assured.


Variablen-Dokumentation

char flags

Holds flags (INFTY, DIV0...).

This is a special "flags" byte: Possible bits so far:

[ 7 6 5 4 3 2 1 0 ] INFTY

char reg[REG_NR][NUMBER_SIZE]

Memory locations for virtual X, Y, Z, T, A, B registers.