; 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
Q1:关于 SIC/XE 机器的第二个假设是否正确?
Q2:上述程序在逻辑上是否正确?
Q3:第 16 页中给出的代码:https ://drive.google.com/file/d/1-Mt59wikepLm8_Bc-eDK8LGKjqQn7lSQ/view?usp=sharing PDF 也是如此,但我放松了执行流程。 . 为什么有 3、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, X
,COMPR X, T
和TIX #99
?