Sheet 2.2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

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 register-
to-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-to-
register instructions as you can to make your code effective and minimized.

1
Answer
1-

LDA CON LOAD CONSTANT 5 INTO A

STA ALPHA STORE A INTO ALPHA


GAMMA RESW 1 ONE-WORD VARIABLE
CON WORD 15 ONE-WORD CONSTANT

2-
LDCH #65 LOAD ASCII CODE OF ‘A’ INTO A

STCH DELTA STORE A INTO DELTA


DELTA RESB 1 ONE-BYTE VARIABLE

3-
LDA 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

4-
LDS BETA LOAD INCR INTO S
LDA ALPHA LOAD ALPHA INTO A
ADDR S,A ADD THE VALUE OF BETA
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

5-
LDX 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

6-
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

STR1 BYTE C’ COPY STRING’ 11-BYTE STRING CONSTANT

3
STR2 RESB 11 11-BYTE VARIABLE

You might also like