Retain the physical control column and buffer printer ink for overprinting. Pack CALL literals into 36-bit BCD, blank-pad the final word and append the all-ones terminator. Keep raw words through binary I/O for either dummy mode. Expand the original-compiler corpus to carriage motion, numerical boundaries, library routines, Hollerith memory and the CHM inversion. Preserve native emulator disagreements and exact fingerprints of the remaining numerical mismatches; strict comparison continues to fail them.
42 lines
1.1 KiB
C
42 lines
1.1 KiB
C
#include "ftn.h"
|
|
|
|
/* IBM 704 six-bit BCD. Unassigned codes are deliberately not accepted as
|
|
ASCII aliases. Lowercase source letters denote the uppercase card punch. */
|
|
int bcd_code(unsigned char c) {
|
|
if (c >= 'a' && c <= 'z')
|
|
c -= 'a' - 'A';
|
|
if (c >= '0' && c <= '9')
|
|
return c - '0';
|
|
if (c >= 'A' && c <= 'I')
|
|
return 021 + c - 'A';
|
|
if (c >= 'J' && c <= 'R')
|
|
return 041 + c - 'J';
|
|
if (c >= 'S' && c <= 'Z')
|
|
return 062 + c - 'S';
|
|
switch (c) {
|
|
case '+': return 020;
|
|
case '-': return 040;
|
|
case ' ': return 060;
|
|
case '/': return 061;
|
|
case '.': return 033;
|
|
case ')': return 034;
|
|
case '$': return 053;
|
|
case '*': return 054;
|
|
case ',': return 073;
|
|
case '(': return 074;
|
|
case '=': return 013;
|
|
default: return -1;
|
|
}
|
|
}
|
|
|
|
uint64_t bcd_word(const char *s, int n) {
|
|
uint64_t word = 0;
|
|
for (int i = 0; i < 6; i++) {
|
|
int code = i < n ? bcd_code((unsigned char)s[i]) : 060;
|
|
if (code < 0)
|
|
ftn_rterror("character is not in the 704 BCD alphabet");
|
|
word = (word << 6) | (unsigned)code;
|
|
}
|
|
return word;
|
|
}
|