SIC/XE Reference

Patterns

For loop

This is a simple program in SIC/XE that takes each word in ALPHA, adds the corresponding word in BETA, and stores the sum in GAMMA. It does this by adding 3 (bytes per word) to the index register X and comparing the value of X to the value in register T, which contains the length of ALPHA, BETA, and GAMMA.

                       .For loop in SIC/XE
       LDS    #3       .Initialize Register S to 3
       LDT    #300     .Initialize Register T to 300
       LDX    #0       .Initialize Index Register to 0
ADDLP  LDA    ALPHA,X  .Load Word from ALPHA into Register A
       ADD    BETA,X   .Add Word From BETA
       STA    GAMMA,X  .Store the Result in a work in GAMMA
       ADDR   S,X      .ADD 3 to INDEX value
       COMPR  X,T      .Compare new INDEX value to 300
       JLT    ADDLP    .Loop if INDEX value is less than 300
ALPHA  RESW   100
BETA   RESW   100
GAMMA  RESW   100

Last updated on

On this page