在 SIC/XE 机器中添加和存储值

Adding and storing value in SIC/XE machine

; Assembly Program

;¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|
;                                   |
;       Programmer: joe247          |
;                                   |
;___|___|___|___|___|___|___|___|___|

; Write a SIC/XE Program program in which ALHPA, BETA and GAMMA are array capable of storing 100 words.
; Add the words in ALPHA and BETA and store it in GAMMA.

; Assumption 1: that the data is already stored in the corresponding locations ALPHA & BETA
; Assumption 2: the memory is a linear array starting from 0
;
; Memory Locations:
;    ______ ______ ______     ______ ______ ______     ______ ______ ______
;   | 0000 | 0001 | 0002 |...| 0100 | 0101 | 0102 |...| 0200 | 0201 | 0202 |...
;    ¯¯¯¯¯¯ ¯¯¯¯¯¯ ¯¯¯¯¯¯     ¯¯¯¯¯¯ ¯¯¯¯¯¯ ¯¯¯¯¯¯     ¯¯¯¯¯¯ ¯¯¯¯¯¯ ¯¯¯¯¯¯
;   X                         S                        T

;LABEL       OPCODE      OPERAND
;-----       ------      -------
             LDX         #0              ; X = 0
             LDS         #100            ; S = 100
             LDT         #200            ; T = 100
 LOOP        LDA         ALPHA, X        ; A = ALPHA[X]
             ADD         BETA, S         ; A += BETA[T]
             STA         GAMMA, T        ; GAMMA[T] = A
             ADD         S, #1           ; A = S + 1
             STA         S               ; S = A
             ADD         T, #1           ; A = T + 1
             STA         T               ; T = A
             TIX         #99             ; check if X <= 99: set flag & X += 1
             JLT         LOOP            ; jump to LOOP if flag is set
;-----------------------------------------------------------------------------
 ALPHA       RESW        100             ; reserve 100 words for ALPHA
 BETA        RESW        100             ; reserve 100 words for BETA
 GAMMA       RESW        100             ; reserve 100 words for GAMMA

问题 1: 第二个假设对于 SIC/XE 机器是否正确?

Q2:以上程序逻辑是否正确?

Q3: 第 16 页中给出的代码:https://drive.google.com/file/d/1-Mt59wikepLm8_Bc-eDK8LGKjqQn7lSQ/view?usp=sharing PDF 做同样的事情,但我失去了执行流程......为什么有三个, 300 和所有?

这是 PDF 中的代码:

; SIC/XE
; ======

            LDS         #3              ; INITIALIZE REGISTER S TO 3
            LDT         #300            ; INITIALIZE REGISTER T TO 300
            LDX         #0              ; INITIALIZE INDEX RESISTER 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 WORD 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
            .
            .
            .                           ; ARRAY VARIABLES --100  WORDS EACH
ALPHA       RESW        100
BETA        RESW        100
GAMMA       RESW        100

我不明白这些是如何工作的:LDA ALPHA, XCOMPR X, TTIX #99?

I don't understand how these work: LDA ALPHA, X, COMPR X, T and TIX #99?

LDA ALPHA, X — 该指令计算地址 ALPHA + X 并将该地址处的字(3 个字节)加载到 A 寄存器中。

COMPR X, T — 该指令将 X 寄存器的值与 T 寄存器的值进行比较,将比较结果设置为 SW(状态字寄存器)中的条件代码。

TIX #99 — 该指令将 X 寄存器的值与立即数 99 进行比较,并将比较结果设置为 SW 寄存器中的条件代码。


the memory is a linear array starting from 0

Is the second assumption correct with respect to an SIC/XE machine?

内存确实是一个线性数组,虽然它从哪里开始有点无关紧要,因为标签抽象了实际位置。


Is the above program logically correct?

不,您的程序混合了字节算术地址计算和字加载,它应该使用字算术地址计算和字加载。

由于单词的长度为 3 个字节,因此您必须将索引加 3 才能找​​到下一个单词。这也是为什么 100 个字(3 字节元素)的数组在 300 字节后停止的原因。