Download Done2

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Sheet (2.2)
1- Write a sequence of SIC instructions that move a value 15 of type word to the
memory location GAMMA.
2- Given that the ASCII code of character ‘A’ is 65 and using immediate
addressing mode, write a sequence of SIC/XE instructions that store the
character ‘A’ into memory location DELTA. Minimize your code as much as
you can.
3- Write a sequence of SIC instructions that calculate the expression ALPHA *
BETA + 10, where ALPHA and BETA are one-word variables. Store the result
of this expression into memory location GAMMA.
4- Write a sequence of SIC/XE instructions that calculate the expression ALPHA
+ BETA - 6, where ALPHA and BETA are one-word variables, and store the
result of this expression into memory location GAMMA. Use as many registerto-register instructions as you can to make your code effective and minimized.
5- Write a sequence of SIC instructions that copy the ‘HELLO WORLD’ character
string form one memory location to another.
6- Write a sequence of SIC/XE instructions that copy the ‘COPY STRING’
character string form one memory location to another. Use as many register-toregister instructions as you can to make your code effective and minimized.
1
Answer
1LDA
CON
LOAD CONSTANT 5 INTO A
STA
ALPHA
STORE A INTO ALPHA
GAMMA
RESW
1
ONE-WORD VARIABLE
CON
WORD
15
ONE-WORD CONSTANT
LDCH
#65
LOAD ASCII CODE OF ‘A’ INTO A
STCH
DELTA
STORE A INTO DELTA
RESB
1
ONE-BYTE VARIABLE
2-
DELTA
3LDA
ALPHA
LOAD ALPHA INTO A
MUL
BETA
MULTIPLY THE VALUE OF BETA
ADD
TEN
ADD 10
STA
GAMMA
STORE A INTO BETA
TEN
WORD
10
ONE-WORD CONSTANT
ALPHA
RESW
1
ONE-WORD VARIABLE
BETA
RESW
1
ONE-WORD VARIABLE
GAMMA
RESW
1
ONE-WORD VARIABLE
LDS
BETA
LOAD INCR INTO S
LDA
ALPHA
LOAD ALPHA INTO A
ADDR
S,A
ADD THE VALUE OF BETA
4-
2
SUB
#1
SUBTRACT 1
STA
GAMMA
STORE IN DELTA
ALPHA
RESW
1
ONE-WORD VARIABLE
BETA
RESW
1
ONE-WORD VARIABLE
GAMMA
RESW
1
ONE-WORD VARIABLE
5LDX
ZERO
SET INDEX REGISTER X TO 0
MOVECH LDCH
STR1,X
LOAD CHAR FROM STR1 INTO A
STCH
STR2,X
STORE A INTO STR2
TIX
ELEVEN
ADD 1 TO X THEN COMPARE TO 11
JLT
MOVECH
LOOP IF INDEX IS LESS THAN 11
STR1
BYTE
C’ HELLO WORLD’
11-BYTE STRING CONSTANT
STR2
RESB
11
11-BYTE VARIABLE
ZERO
WORD
0
ONE-WORD CONSTANT
ELEVEN
WORD
11
ONE-WORD CONSTANT
LDT
#11
SET REGISTER T TO 11
LDX
#0
SET INDEX REGISTER X TO 0
MOVECH LDCH
STR1,X
LOAD CHAR FROM STR1 INTO A
STCH
STR2,X
STORE A INTO STR2
TIXF
T
ADD 1 TO X THEN COMPARE TO 11
JLT
MOVECH
LOOP IF INDEX IS LESS THAN 11
BYTE
C’ COPY STRING’
11-BYTE STRING CONSTANT
6-
STR1
3
STR2
RESB
11
11-BYTE VARIABLE
4