/*
* Z80 - Assembler
* Copyright (C) 1987-1992 by Udo Munk
*
* History:
* 17-SEP-1987 Development under Digital Research CP/M 2.2
* 28-JUN-1988 Switched to Unix System V.3
*/
/*
* Dieses Modul enthaelt die numerischen
* Rechen- und Umwandlungsfunktionen.
*/
/*
* Umwandlung eines ASCII-Strings mit einer Hexzahl in
* einen Integer.
* Format: nnnnH oder 0nnnnH wenn 1.Ziffer > 9
*/
axtoi(str)
register char *str;
{
register int num;
num = 0;
while (isxdigit(*str)) {
num *= 16;
num += *str - ((*str <= '9') ? '0' : '7');
str++;
}
return(num);
}
/*
* Umwandlung eines ASCII-Strings mit einer Oktalzahl in
* einen Integer.
* Format: nnnnO
*/
aotoi(str)
register char *str;
{
register int num;
num = 0;
while ('0' <= *str && *str <= '7') {
num *= 8;
num += (*str++) - '0';
}
return(num);
}
/*
* Umwandlung eines ASCII-Strings mit einer Binaerzahl in
* einen Integer.
* Format: nnnnnnnnnnnnnnnnB
*/
abtoi(str)
register char *str;
{
register int num;
num = 0;
while ('0' <= *str && *str <= '1') {
num *= 2;
num += (*str++) - '0';
}
return(num);
}
/*
* Umwandlung eines ASCII-Strings in einen Integer.
*/
strval(str)
register char *str;
{
register int num;
num = 0;
while (*str) {
num <<= 8;
num += (int) *str++;
}
return(num);
}
/*
* Die Funktion prueft einen Wert auf -256 < Wert < 256
* Output: Wert wenn im Bereich, sonst 0 und Fehlermeldung
*/
chk_v1(i)
register int i;
{
if (i >= -255 && i <= 255)
return(i);
else {
asmerr(E_VALOUT);
return(0);
}
}
/*
* Die Funktion prueft einen Wert auf -128 < Wert < 128
* Output: Wert wenn im Bereich, sonst 0 und Fehlermeldung
*/
chk_v2(i)
register int i;
{
if (i >= -127 && i <= 127)
return(i);
else {
asmerr(E_VALOUT);
return(0);
}
}