Some IBM 1130 code written in 1971

52 views
Skip to first unread message

Peter Diehr

unread,
Oct 26, 2024, 3:52:55 PM10/26/24
to ibm...@googlegroups.com
One day a question arose - can arithmetic be done on the IBM 1130 without using the arithmetic commands?  Of course, I immediately knew that it was certainly possible - I had worked on computers that had no intrinsic arithmetic capability, such as the IBM 1620 (you loaded the multiplication table with a deck of cards!) and of course, the electronic circuits which implement arithmetic instructions just use logic: and, or, not.  

So I piped up "Sure! I can do it!"  So I spent the lunch hour working out this bit of code.  It was never tested, but we were convinced that it would work.  It can now be tried on the IBM 1130 emulator.

None of the data items were declared.  Red felt tip pens were popular in the Instructional Computer Service computer center that year.  So were pocket protectors.

Best regards,  Peter Diehr
With contemporary campus newspaper photo from 1970.
1970-Peter Diehr at IBM 1130 console, EMU ICS. Photo from campus news.jpg

1971-IBM 1130 Contest-Arithmetic with arithmetic, by Peter Diehr.jpg

Claudio Vincenzi - GMail

unread,
Oct 27, 2024, 12:14:02 PM10/27/24
to ibm...@googlegroups.com, Peter Diehr, Bob Flanders, Carl Claunch
Hi professor Diehr,

I saw your code and could not resist putting my hands on it and then typing and testing it.
I created a job having two ASM functions:
  1. INTEGER FUNCTION ARADD (n1,n2)
  2. INTEGER FUNCTION LGADD (n1,n2)

ARADD() performs the sum off n1 and n2 using the CPU arithmetic A instruction
LGADD() performs the sum off n1 and n2 using your algorithm

I played with the dates as if we were back in the 70s developing this.

Job source code is attached.

Job output follows below.

att
Claudio Vincenzi


PAGE   1

// JOB    1234

LOG DRIVE   CART SPEC   CART AVAIL  PHY DRIVE
  0000        1234        1234        0000

V2 M12   ACTUAL 32K  CONFIG 16K
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PAGE   1    LOGADDER

// JOB                                            LOGADDER

LOG DRIVE   CART SPEC   CART AVAIL  PHY DRIVE
  0000        1234        1234        0000

V2 M12   ACTUAL 32K  CONFIG 16K

// ** LOGICAL ADDER FUNCTION

// ASM
*LIST
*PRINT SYMBOL TABLE
                 00001    ***************************************************
                 00002    * THIS ROUTINE WILL ADD TWO INTEGERS              *
                 00003    * TOGETHER, AND TURN ON THE OVERFLOW              *
                 00004    * INDICATOR IF ARITHMETIC OVERFLOW OCCURS         *
                 00005    * WITHOUT USING ANY ARITHMETIC INSTRUCTIONS       *
                 00006    ***************************************************
                 00007    * USING IBM-1130 CPU LOGICAL INSTRUCTIONS ONLY    *
                 00008    ***************************************************
                 00009    * DIEHR, PETER         SYSTEMS PROGRAMMER         *
                 00010    * EMU INSTRUCTIONAL COMPUTER SERVICE, 1971        *
                 00011    ***************************************************
                 00012    * VINCENZI, CLAUDIO    SYSTEMS PROGRAMMER         *
                 00013    * CENTRO DE PROCESSAMENTO DE DADOS EESC USP, 1978 *
                 00014    ***************************************************
0000    131C1104 00015          ENT     LGADD           FUNCTION ENTRY POINT
0000 0  0000     00016    LGADD DC      *-*             RETURN ADDRESS
0001 01 C4800000 00017          LD   I  LGADD           ACC)-- LGDDR     (LGADD POINTS
0003 0  D024     00018          STO     ADD1            SAVE 1ST ARG ADDR
0004 01 74010000 00019          MDX  L  LGADD,1         INCREMENT LGADD
0006 01 C4800000 00020          LD   I  LGADD    ACC)-- LGDDR     (LGADD POINTS TO ADD
0008 0  D020     00021          STO     ADD2            SAVE 2ND ARG ADDR
                 00022    * DO THE MATH...
0009 0  C01E     00023          LD      ADD1             GET 1ST ADDEND AND SAVE
000A 0  D01F     00024          STO     SIGN            *IT (FOR LATER ANALYSIS)
000B 0  F01D     00025          EOR     ADD2             EXCLUSIVE OR WITH WND ADDEND
000C 0  D01E     00026          STO     STATS           *RESULT IS NEGATIVE ONLY IFF
                 00027    *                              THEY ARE OF OPPOSITE SIGN
000D 0  C01A     00028    LOOP  LD      ADD1             FETCH 1ST ADDEND
000E 0  E81A     00029          OR      ADD2             'OR'  WITH 2ND ADDEND
000F 0  D01C     00030          STO     SUM             *AND SAVE PARTIAL SUM
0010 0  C017     00031          LD      ADD1             FETCH 1ST ADDEND
0011 0  E017     00032          AND     ADD2            *'AND' WITH 2ND ADDEND
0012 0  1001     00033          SLA     1               *AND MULTIPLY BY BASE (=2)
0013 0  D014     00034          STO     ADD1             THIS REPRESENTS THE 'CARRIES'
0014 0  1801     00035          SRA     1                RESTORE TEMPORARILY
0015 0  F016     00036          EOR     SUM             *AND CHANGE PARTIAL SUMS
0016 0  D012     00037          STO     ADD2            *TO REFLECT CARRIES PENDING
0017 0  C010     00038          LD      ADD1             CHECK FOR CARRIES PENDING
0018 0  4820     00039          SKP     Z                SKIP OUT IF NONE (=0)
0019 0  70F3     00040          B       LOOP            *ELSE CONTINUES PROCESS
001A 0  C010     00041          LD      STATS            ADD COMPLETE - SIGN ANALYSIS
001B 0  4828     00042          SKP     Z+               DON'T SKIP IF ORIGINALS HAD
001C 0  7005     00043          B       DONE             OPPOSITE SIGNS-IF SO, COMPLET
001D 0  C00C     00044          LD      SIGN             OTHERWISE FETCH REPRESENTATIO
001E 0  F00A     00045          EOR     ADD2            *SIGN AND TEST IF RESULT
001F 0  4810     00046          SKP     -               *HAS THE SAME SIGN
0020 0  7001     00047          B       DONE             OK IF SAME SIGN
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PAGE   2    LOGADDER

0021 0  2001     00048          LDS     1               *ELSE TURN ON OVERFLOW
                 00049    *
0022             00050    DONE  EQU     *
                 00051    *
0022 0  C009     00052          LD      SUM             RETURN VALUE (SUM)
                 00053    *
0023 01 74010000 00054          MDX  L  LGADD,1         INCREMENT MADDR TO CORRECT RET
0025 0  1000     00055          NOP
0026 01 4C800000 00056          BSC  I  LGADD    RETURN TO CALLER
                 00057    *
0028 0  0000     00058    ADD1  DC      0
0029 0  0000     00059    ADD2  DC      0
002A 0  0000     00060    SIGN  DC      0
002B 0  0000     00061    STATS DC      0
002C 0  0000     00062    SUM   DC      0
002E             00063          END     LGADD    RETURN TO CALLER
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PAGE   3    LOGADDER      *SYMBOL TABLE*

   ADD1   0028     ADD2   0029     DONE   0022     LGADD  0000     LOOP   000D
   SIGN   002A     STATS  002B     SUM    002C

   000 OVERFLOW SECTORS SPECIFIED
   000 OVERFLOW SECTORS REQUIRED
   008 SYMBOLS DEFINED
    NO ERROR(S) AND   NO WARNING(S)  FLAGGED IN ABOVE ASSEMBLY

// DUP

*DELETE         UA  LGADD
CART ID 1234   DB ADDR  2A1E   DB CNT   0004

*STORE      WS  UA  LGADD
CART ID 1234   DB ADDR  2A20   DB CNT   0004

// ** ARITHMETIC ADDER FUNCTION

// ASM
*LIST
*PRINT SYMBOL TABLE
                 00001    ***************************************************
                 00002    * THIS ROUTINE WILL ADD TWO INTEGERS              *
                 00003    * TOGETHER, AND TURN ON THE OVERFLOW              *
                 00004    * INDICATOR IF ARITHMETIC OVERFLOW OCCURS         *
                 00005    * USING CPU ARITHMETIC INSTRUCTIONS               *
                 00006    ***************************************************
                 00007    * USING IBM-1130 CPU ARITHMETIC INSTRUCTIONS ONLY *
                 00008    ***************************************************
                 00009    * DIEHR, PETER         SYSTEMS PROGRAMMER         *
                 00010    * EMU INSTRUCTIONAL COMPUTER SERVICE, 1971        *
                 00011    ***************************************************
                 00012    * VINCENZI, CLAUDIO    SYSTEMS PROGRAMMER         *
                 00013    * CENTRO DE PROCESSAMENTO DE DADOS EESC USP, 1978 *
                 00014    ***************************************************
0000    01641104 00015          ENT     ARADD           FUNCTION ENTRY POINT
0000 0  0000     00016    ARADD DC      *-*             RETURN ADDRESS
0001 01 C4800000 00017          LD   I  ARADD           ACC)-- LGDDR     (ARADD POINTS
0003 0  D00E     00018          STO     N1              SAVE 1ST ARG ADDR
0004 01 74010000 00019          MDX  L  ARADD,1         INCREMENT ARADD
0006 01 C4800000 00020          LD   I  ARADD    ACC)-- LGDDR     (ARADD POINTS TO ADD
0008 0  D00A     00021          STO     N2              SAVE 2ND ARG ADDR
                 00022    * DO THE MATH...
0009 01 C4800012 00023          LD   I  N1              LOAD 1ST ARG VALUE
000B 01 84800013 00024          A    I  N2              ADD  2ND ARG VALUE
                 00025    *
000D 01 74010000 00026          MDX  L  ARADD,1         INCREMENT MADDR TO CORRECT RET
000F 0  1000     00027          NOP
0010 01 4C800000 00028          BSC  I  ARADD
                 00029    *
0012 0  0000     00030    N1    DC      0
0013 0  0000     00031    N2    DC      0
0014 0  0000     00032    SUM   DC      0
0016             00033          END     ARADD    RETURN TO CALLER
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PAGE   4    LOGADDER      *SYMBOL TABLE*

   ARADD  0000     N1     0012     N2     0013     SUM    0014

   000 OVERFLOW SECTORS SPECIFIED
   000 OVERFLOW SECTORS REQUIRED
   004 SYMBOLS DEFINED
    NO ERROR(S) AND   NO WARNING(S)  FLAGGED IN ABOVE ASSEMBLY

// DUP

*DELETE         UA  ARADD
CART ID 1234   DB ADDR  2A1E   DB CNT   0002

*STORE      WS  UA  ARADD
CART ID 1234   DB ADDR  2A22   DB CNT   0002

// FOR
*LIST ALL
*ONE WORD INTEGERS
*IOCS(1132PRINTER)
** TEST OF ADD FUNCTIONS
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PAGE   5    LOGADDER   TEST OF ADD FUNCTIONS

C     ****************************************************
C     * THIS PROGRAM WILL TEST TWO ADD INTEGER FUNCTIONS *
C     ****************************************************
C     * USING IBM-1130 BASIC FORTRAN                     *
C     ****************************************************
C     * DIEHR, PETER         SYSTEMS PROGRAMMER          *
C     * EMU INSTRUCTIONAL COMPUTER SERVICE, 1971         *
C     ****************************************************
C     * VINCENZI, CLAUDIO    SYSTEMS PROGRAMMER          *
C     * CENTRO DE PROCESSAMENTO DE DADOS EESC USP, 1978  *
C     ****************************************************
      INTEGER N1, N2, SUM
      INTEGER ARADD
C
      WRITE(3,300)
300   FORMAT(' TEST OF THE ARITHMETIC ADD ARADD() FUNCTION')
C
      N1=67
      N2=33
      SUM=ARADD(N1,N2)
C
      WRITE(3,310) N1,N2,SUM
310   FORMAT(' SUM OF N1=',I3,' AND N2=',I3,' ARADD() RETURNS ',I4,/)
C
      WRITE(3,330)
330   FORMAT(' TEST OF THE LOGICAL ADD LGADD() FUNCTION')
C
      N1=67
      N2=33
      SUM=LGADD(N1,N2)
C
      WRITE(3,320) N1,N2,SUM
320   FORMAT(' SUM OF N1=',I3,' AND N2=',I3,' LGADD() RETURNS ',I4,/)
C
      WRITE(3,390)
390   FORMAT(' CALL EXIT...')
      CALL EXIT
      END
VARIABLE ALLOCATIONS
    N1(I )=0000         N2(I )=0001        SUM(I )=0002

STATEMENT ALLOCATIONS
 300  =0007  310  =001F  330  =003A  320  =0051  390  =006C

FEATURES SUPPORTED
 ONE WORD INTEGERS
 IOCS

CALLED SUBPROGRAMS
 ARADD   LGADD   FLD     FSTO    PRNTZ   SWRT    SCOMP   SFIO    SIOI

INTEGER CONSTANTS
     3=0004     67=0005     33=0006

CORE REQUIREMENTS FOR
 COMMON      0  VARIABLES      4  PROGRAM    198

END OF COMPILATION
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PAGE   6    LOGADDER

// XEQ

TEST OF THE ARITHMETIC ADD ARADD() FUNCTION
SUM OF N1= 67 AND N2= 33 ARADD() RETURNS  100

TEST OF THE LOGICAL ADD LGADD() FUNCTION
SUM OF N1= 67 AND N2= 33 LGADD() RETURNS 1021


+ [[ CPU STOPPING ]]



--
IBM1130 discord channel: https://discord.gg/nrFEMt48mE
---
You received this message because you are subscribed to the Google Groups "IBM1130" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ibm1130+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ibm1130/CACWfJ_STvopPeJYtMdh1_AW59FjKbF_q-Hb9%2B95x%2BuB8KOuw8Q%40mail.gmail.com.


--
Claudio Vincenzi
logadder.job

Peter Diehr

unread,
Oct 27, 2024, 12:46:04 PM10/27/24
to Claudio Vincenzi - GMail, ibm...@googlegroups.com, Bob Flanders, Carl Claunch
Thanks, I'll take a look. This is the story of untested code ... never quite right!

Best regards, Peter Diehr

Claudio Vincenzi - GMail

unread,
Oct 28, 2024, 8:17:05 PM10/28/24
to Peter Diehr, ibm...@googlegroups.com, Bob Flanders, Carl Claunch
Dear professor Diehr

seems that your assembly code and algorithm are absoluelly correct and works perfectly.
The problem was with the assembly code I added. The ENTRY code section was missing some instructions. Instead of dealing with the argument values your code was being supplied with their addresses - I miss to de-reference them!

                 00029    * DE-REFERENCE ARGS 1 AND 2
                 00030    *
000E 01 C4800036 00031          LD   I  ADD1            ACC )-- ADDR OF 1ST ARG
0010 0  D025     00032          STO     ADD1            ADD1 )-- 1ST ARG
0011 01 C4800037 00033          LD   I  ADD2            ACC )-- ADDR OF 2ND ARG
0013 0  D023     00034          STO     ADD2            ADD2 )-- 2ND ARG
                 00035    
*
  

So, now the tests produce the expected results. Congratulations professor - this is a really historic piece of computer programming art!
I added a 3rd argument to LGADD() function. Now it looks like this:

 LGADD( n1, n2, OVRFL ) 

where OVRFL argument returns a boolean value (1=TRUE) indicating whether the sum operation resulted in overflow or not

Follows the code and job listing.

+ [[ CPU RUNNING ]]


PAGE   1

// JOB    1234

LOG DRIVE   CART SPEC   CART AVAIL  PHY DRIVE
  0000        1234        1234        0000

V2 M12   ACTUAL 16K  CONFIG 16K

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PAGE   1    LOGADDER

// JOB                                            LOGADDER

LOG DRIVE   CART SPEC   CART AVAIL  PHY DRIVE
  0000        1234        1234        0000

V2 M12   ACTUAL 16K  CONFIG 16K


// ** LOGICAL ADDER FUNCTION

// ASM
*LIST
*PRINT SYMBOL TABLE
                 00001    ***************************************************
                 00002    * THIS ROUTINE WILL ADD TWO INTEGERS              *
                 00003    * TOGETHER, AND TURN ON THE OVERFLOW              *
                 00004    * INDICATOR IF ARITHMETIC OVERFLOW OCCURS         *
                 00005    * WITHOUT USING ANY ARITHMETIC INSTRUCTIONS       *
                 00006    ***************************************************
                 00007    * USING IBM-1130 CPU LOGICAL INSTRUCTIONS ONLY    *
                 00008    ***************************************************
                 00009    * DIEHR, PETER         SYSTEMS PROGRAMMER         *
                 00010    * EMU INSTRUCTIONAL COMPUTER SERVICE, 1971        *
                 00011    ***************************************************
                 00012    * VINCENZI, CLAUDIO    SYSTEMS PROGRAMMER         *
                 00013    * CENTRO DE PROCESSAMENTO DE DADOS EESC USP, 1978 *
                 00014    ***************************************************
0000    131C1104 00015          ENT     LGADD           FUNCTION ENTRY POINT
0000 0  0000     00016    LGADD DC      *-*             RETURN ADDRESS
                 00017    *
0001 01 C4800000 00018          LD   I  LGADD           ACC)-- LGDDR     (LGADD POINTS
0003 0  D032     00019          STO     ADD1            SAVE 1ST ARG ADDR
0004 01 74010000 00020          MDX  L  LGADD,1         INCREMENT LGADD
                 00021    *
0006 01 C4800000 00022          LD   I  LGADD    ACC)-- LGDDR     (LGADD POINTS TO ADD
0008 0  D02E     00023          STO     ADD2            SAVE 2ND ARG ADDR
0009 01 74010000 00024          MDX  L  LGADD,1         INCREMENT LGADD
                 00025    *
000B 01 C4800000 00026          LD   I  LGADD    ACC)-- LGDDR     (LGADD POINTS TO ADD
000D 0  D02D     00027          STO     OVRFL           SAVE 3ND ARG ADDR (OVERFLOW FL
                 00028    *
                 00029    * DE-REFERENCE ARGS 1 AND 2
                 00030    *
000E 01 C4800036 00031          LD   I  ADD1            ACC )-- ADDR OF 1ST ARG
0010 0  D025     00032          STO     ADD1            ADD1 )-- 1ST ARG
0011 01 C4800037 00033          LD   I  ADD2            ACC )-- ADDR OF 2ND ARG
0013 0  D023     00034          STO     ADD2            ADD2 )-- 2ND ARG
                 00035    *
                 00036    * DO THE MATH...
                 00037    *
0014 0  C021     00038          LD      ADD1             GET 1ST ADDEND AND SAVE
0015 0  D022     00039          STO     SIGN            *IT (FOR LATER ANALYSIS)
0016 0  F020     00040          EOR     ADD2             EXCLUSIVE OR WITH 2ND ADDEND
0017 0  D021     00041          STO     STATS           *RESULT IS NEGATIVE ONLY IFF
                 00042    *                              THEY ARE OF OPPOSITE SIGN
0018 0  C01D     00043    LOOP  LD      ADD1             FETCH 1ST ADDEND
0019 0  E81D     00044          OR      ADD2             'OR'  WITH 2ND ADDEND
001A 0  D01F     00045          STO     SUM             *AND SAVE PARTIAL SUM
001B 0  C01A     00046          LD      ADD1             FETCH 1ST ADDEND
001C 0  E01A     00047          AND     ADD2            *'AND' WITH 2ND ADDEND

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PAGE   2    LOGADDER

001D 0  1001     00048          SLA     1               *AND MULTIPLY BY BASE (=2)
001E 0  D017     00049          STO     ADD1             THIS REPRESENTS THE 'CARRIES'
001F 0  1801     00050          SRA     1                RESTORE TEMPORARILY
0020 0  F019     00051          EOR     SUM             *AND CHANGE PARTIAL SUMS
0021 0  D015     00052          STO     ADD2            *TO REFLECT CARRIES PENDING
0022 0  C013     00053          LD      ADD1             CHECK FOR CARRIES PENDING
0023 0  4820     00054          SKP     Z                SKIP OUT IF NONE (=0)
0024 0  70F3     00055          B       LOOP            *ELSE CONTINUES PROCESS
0025 0  C013     00056          LD      STATS            ADD COMPLETE - SIGN ANALYSIS
0026 0  4828     00057          SKP     Z+               DON'T SKIP IF ORIGINALS HAD
0027 0  7008     00058          B       DONE             OPPOSITE SIGNS-IF SO, COMPLET
0028 0  C00F     00059          LD      SIGN             OTHERWISE FETCH REPRESENTATIO
0029 0  F00D     00060          EOR     ADD2            *SIGN AND TEST IF RESULT
002A 0  4810     00061          SKP     -               *HAS THE SAME SIGN
002B 0  7004     00062          B       DONE             OK IF SAME SIGN
002C 0  2001     00063          LDS     1               *ELSE TURN ON OVERFLOW
002D 0  C00E     00064          LD      ONE
002E 01 D480003B 00065          STO  I  OVRFL           SET 3D ARG TO 1 IF OVERFLOW
                 00066    *
0030             00067    DONE  EQU     *
                 00068    *
0030 0  C009     00069          LD      SUM             RETURN VALUE (SUM)
                 00070    *
0031 01 74010000 00071          MDX  L  LGADD,1         INCREMENT MADDR TO CORRECT RET
0033 0  1000     00072          NOP
0034 01 4C800000 00073          BSC  I  LGADD    RETURN TO CALLER
                 00074    *
0036 0  0000     00075    ADD1  DC      0
0037 0  0000     00076    ADD2  DC      0
0038 0  0000     00077    SIGN  DC      0
0039 0  0000     00078    STATS DC      0
003A 0  0000     00079    SUM   DC      0
003B 0  0000     00080    OVRFL DC      0
003C 0  0001     00081    ONE   DC      1
003E             00082          END     LGADD    RETURN TO CALLER

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PAGE   3    LOGADDER      *SYMBOL TABLE*

   ADD1   0036     ADD2   0037     DONE   0030     LGADD  0000     LOOP   0018
   ONE    003C     OVRFL  003B     SIGN   0038     STATS  0039     SUM    003A


   000 OVERFLOW SECTORS SPECIFIED
   000 OVERFLOW SECTORS REQUIRED
   010 SYMBOLS DEFINED

    NO ERROR(S) AND   NO WARNING(S)  FLAGGED IN ABOVE ASSEMBLY

// DUP

*DELETE         UA  LGADD
CART ID 1234   DB ADDR  2793   DB CNT   0005

*STORE      WS  UA  LGADD
CART ID 1234   DB ADDR  2795   DB CNT   0005
CART ID 1234   DB ADDR  2793   DB CNT   0002

*STORE      WS  UA  ARADD
CART ID 1234   DB ADDR  2798   DB CNT   0002


// FOR
*LIST ALL
*ONE WORD INTEGERS
*IOCS(1132PRINTER)
** TEST OF ADD FUNCTIONS
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PAGE   5    LOGADDER   TEST OF ADD FUNCTIONS

C     ****************************************************
C     * THIS PROGRAM WILL TEST TWO ADD INTEGER FUNCTIONS *
C     ****************************************************
C     * USING IBM-1130 BASIC FORTRAN                     *
C     ****************************************************
C     * DIEHR, PETER         SYSTEMS PROGRAMMER          *
C     * EMU INSTRUCTIONAL COMPUTER SERVICE, 1971         *
C     ****************************************************
C     * VINCENZI, CLAUDIO    SYSTEMS PROGRAMMER          *
C     * CENTRO DE PROCESSAMENTO DE DADOS EESC USP, 1978  *
C     ****************************************************
      INTEGER N1, N2, SUM, OVRFL
      INTEGER ARADD,LGADD
C
      WRITE(3,300)
300   FORMAT(' TEST OF THE ARITHMETIC ADD ARADD() FUNCTION'/)
C
      N1=0
      N2=0
      SUM=ARADD(N1,N2)
C
      WRITE(3,310) N1,N2,SUM
C
      N1=0
      N2=1
      SUM=ARADD(N1,N2)
C
      WRITE(3,310) N1,N2,SUM
C
      N1=1
      N2=0
      SUM=ARADD(N1,N2)
C
      WRITE(3,310) N1,N2,SUM
C
      N1=1
      N2=1
      SUM=ARADD(N1,N2)
C
      WRITE(3,310) N1,N2,SUM

C
      N1=67
      N2=33
      SUM=ARADD(N1,N2)
C
      WRITE(3,310) N1,N2,SUM
C
310   FORMAT(' SUM OF N1=',I5,' AND N2=',I5,
     *       ' LGADD() RETURNS ',I6)
C
      WRITE(3,330)
330   FORMAT(' TEST OF THE LOGICAL ADD LGADD() FUNCTION'/)
C
      N1=0
      N2=0
      OVRFL=0
      SUM=LGADD(N1,N2,OVRFL)
C
      WRITE(3,320) N1,N2,SUM,OVRFL

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PAGE   6    LOGADDER   TEST OF ADD FUNCTIONS

C
      N1=0
      N2=1
      OVRFL=0
      SUM=LGADD(N1,N2,OVRFL)
C
      WRITE(3,320) N1,N2,SUM,OVRFL
C
      N1=1
      N2=0
      OVRFL=0
      SUM=LGADD(N1,N2,OVRFL)
C
      WRITE(3,320) N1,N2,SUM,OVRFL
C
      N1=1
      N2=1
      OVRFL=0
      SUM=LGADD(N1,N2,OVRFL)
C
      WRITE(3,320) N1,N2,SUM,OVRFL
C
      N1=67
      N2=33
      OVRFL=0
      SUM=LGADD(N1,N2,OVRFL)
C
      WRITE(3,320) N1,N2,SUM,OVRFL
C
      N1=1023
      N2=511
      OVRFL=0
      SUM=LGADD(N1,N2,OVRFL)
C
      WRITE(3,320) N1,N2,SUM,OVRFL
C
      N1=10240
      N2=8192
      OVRFL=0
      SUM=LGADD(N1,N2,OVRFL)
C
      WRITE(3,320) N1,N2,SUM,OVRFL
C
      N1=16384
      N2=16383
      OVRFL=0
      SUM=LGADD(N1,N2,OVRFL)
C
      WRITE(3,320) N1,N2,SUM,OVRFL
C
      N1=16384
      N2=16384
      OVRFL=0
      SUM=LGADD(N1,N2,OVRFL)
C
      WRITE(3,320) N1,N2,SUM,OVRFL
C
320   FORMAT(' SUM OF N1=',I5,' AND N2=',I5,
     *       ' LGADD() RETURNS ',I6,' OVRFL=',I4)

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PAGE   7    LOGADDER   TEST OF ADD FUNCTIONS

C

      WRITE(3,390)
390   FORMAT(' CALL EXIT...')
      CALL EXIT
      END
VARIABLE ALLOCATIONS
    N1(I )=0000         N2(I )=0001        SUM(I )=0002      OVRFL(I )=0003

STATEMENT ALLOCATIONS
 300  =000F  310  =0028  330  =0042  320  =005A  390  =007A


FEATURES SUPPORTED
 ONE WORD INTEGERS
 IOCS

CALLED SUBPROGRAMS
 ARADD   LGADD   FLD     FSTO    PRNTZ   SWRT    SCOMP   SFIO    SIOI

INTEGER CONSTANTS
     3=0004      0=0005      1=0006     67=0007     33=0008   1023=0009    511=000A  10240=000B   8192=000C  16384=000D
 16383=000E

CORE REQUIREMENTS FOR
 COMMON      0  VARIABLES      4  PROGRAM    562

END OF COMPILATION


// XEQ

TEST OF THE ARITHMETIC ADD ARADD() FUNCTION

SUM OF N1=    0 AND N2=    0 LGADD() RETURNS      0
SUM OF N1=    0 AND N2=    1 LGADD() RETURNS      1
SUM OF N1=    1 AND N2=    0 LGADD() RETURNS      1
SUM OF N1=    1 AND N2=    1 LGADD() RETURNS      2
SUM OF N1=   67 AND N2=   33 LGADD() RETURNS    100

TEST OF THE LOGICAL ADD LGADD() FUNCTION

SUM OF N1=    0 AND N2=    0 LGADD() RETURNS      0 OVRFL=   0
SUM OF N1=    0 AND N2=    1 LGADD() RETURNS      1 OVRFL=   0
SUM OF N1=    1 AND N2=    0 LGADD() RETURNS      1 OVRFL=   0
SUM OF N1=    1 AND N2=    1 LGADD() RETURNS      2 OVRFL=   0
SUM OF N1=   67 AND N2=   33 LGADD() RETURNS    100 OVRFL=   0
SUM OF N1= 1023 AND N2=  511 LGADD() RETURNS   1534 OVRFL=   0
SUM OF N1=10240 AND N2= 8192 LGADD() RETURNS  18432 OVRFL=   0
SUM OF N1=16384 AND N2=16383 LGADD() RETURNS  32767 OVRFL=   0
SUM OF N1=16384 AND N2=16384 LGADD() RETURNS -32768 OVRFL=   1

+ [[ CPU STOPPING ]]

$
$ Stop due 'CPU WAIT', (stop code=01), CPU Wait for Program Start
$ -------- '--------', (------------), --------------------------
$ Stopped with: IAR: 0x002A SAR: 0x0029 SBR: 0x3000
$ Stopped   at: IAR: 0x0029 (0x0000 0x00 0x00 S               +0x00 (  +0))
$ Followed  by: IAR: 0x002A (0x4C80 0x09 BSC  I       0x0028  +0x00 (  +0))
$ Elapsed Time:  18s
$ ACC Code: 0x1000, intervention required on 1442 Card RP/P
$ ---------------------------------------------------------------

[Mon Oct 28 21:05:24 2024] sim>


On Mon, Oct 28, 2024 at 6:24 PM Peter Diehr <pdi...@gmail.com> wrote:
Claudio:

I seem to need simpler test cases, for example:

N1=1
N2=0
WRITE(3,320) N1,NE,LGADD(N1,N2)
N1=0
N2=1
WRITE(3,320) N1,NE,LGADD(N1,N2)
N1=7
N2=8
WRITE(3,320) N1,NE,LGADD(N1,N2)
N1=1
N2=1
WRITE(3,320) N1,NE,LGADD(N1,N2)
N1=3
N2=1
WRITE(3,320) N1,NE,LGADD(N1,N2)
N1=1
N2=3
WRITE(3,320) N1,NE,LGADD(N1,N2)

This will provide several easy to follow cases, with planned carries.

In the old days, I would have done one of three things:
1. looked hard enough to find the error - but this isn't working for me today!
2. Run this segment in single step mode, checking what is being done - not available to me today.
3. Run my handy single step mode debugger program, which would print an execution trace, along with data dumps of altered registers and data items.  But the code for this is long gone ...

So if you can run these test cases for me, Claudio, I can maybe make some progress.

Two questions on the IBM 1130 emulator: does it carry out every instruction exactly the way the IBM 1130 did?  This code has some assumptions:

1. Logical operators, OR, AND, XOR work simultaneously on all 16 bits of the word.  Programs like Excel do NOT, hence I cannot replicate the logic with an Excel spreadsheet, which I tried yesterday.

I'm hoping to get past this with these test cases.

Thanks, Claudio!

Best regards, Peter Diehr



--
Claudio Vincenzi

Peter Diehr

unread,
Oct 28, 2024, 9:10:16 PM10/28/24
to Claudio Vincenzi - GMail, ibm...@googlegroups.com, Bob Flanders, Carl Claunch

Claudio, thank you so much for the great news!   Proving once again that arithmetic can be done with logic alone.

Best regards, Peter Diehr
Ann Arbor, Michigan

Reply all
Reply to author
Forward
0 new messages