Вы находитесь на странице: 1из 5

1. Write a sequence of instructions for sic to initialize 26 locations with ASCII code for A to Z.

Mention comments to explain each instruction.

LOOP

LDA ZERO STA INDEX LDA 'A' STA ASCII LDA ASCII ADD ONE STA ASCII LDA INDEX ADD ONE STA INDEX COMP K26 JLT LOOP INDEX RESB 1 ASCII RESB 26 ZERO WORD 0 K26 WORD 26 ONE WORD 1

initialize index value to 0 store ascii value of 'A ' in accumulator store the value in location ascii add 1 to the value in ascii to get the ascii value of the next alphabet store the new value in ascii load value of index in the accumulator add 1 to index value to get next memory location store the new index value in index compare the index value to 26 jump if less than to loop

2.

Write a program for SIC/XE to add 2 array each having 100 elements & each elements are 1 word in lenth and store the result back in memory

LDS #3 LDT #300 LDX #0 ADDLP LDA ALPHA,X ADD BETA,X STA GAMMA,X ADDR S,X COMPR X,T JLT ADDLP . . . ALPHA RESW 100 BETA RESW 100 GAMMA RESW 100 ----------------------------------------------------------------------------------------------------------------------------- ------

3.

With reference to SIC standard version explain instruction format.

All machine instructions on the standard version of SIC have the following 24-bit format. 8 Opcode 1 X 15 Address

The flag bit x is used to indicate indexed-addressing mode.

X=0 X=1 Example:

indicate DIRECT addressing mode. indicate INDEXED addressing mode.

LDA TEN (Direct addressing mode) 0000 00000 001 0 0 STCH BUFFER,X (Indexed addressing mode) 0101 10100 001 5 4 0000 1 0000 0000 0 0 0 0000 1 0000 0000 0 0 0

4) . What are different ways of specifying an operand value in a source statement? What are the advantages and disadvantages of each? [4] Ans: There are two ways of specifying operands in the source statements. The operand data can be referred using registers or it can refer to memory locations directly. The advantage of using registers for operand specification is that i) Code generation becomes easy. ii) Data can be retained for a long period in the register

The disadvantage of using register for operand specifications is that it leads to longer instructions. On the other hand, the advantage of using memory variables or locations operand specification is that the instruction becomes short but it makes difficult to generate efficient code. *----------------------------------------------------------------* ----------------------------------------------------------------------------------------------------------------------------- -----------

5. with reference to SIC/XE machine architecture explain.


*Instruction format *Address modes *Data formats *Registers SIC/XE machine architecture _ Instruction formats _ Since the memory used by SIC/XE may be 220 bytes, the instruction format of SIC is not enough. _ Solutions _ Use relative addressing 8 1 15 Opcode X address Extend the address field to 20 bits _ SIC/XE instruction formats Format 1 (1 byte) op (8) Format 2 (2 byte) op(8) r1 (4) r2 (4) Format 3 (3 byte) op(6) n i x b p e disp(12) Format 4 (4 byte) op(6) n I x b p e address(20) e=0;format 3,e=1;format 4 _ Addressing modes _ New relative addressing modes for format 3 Mode Base relative Program-counter relative Indication b=1,p=0 b=0,p=1 Target address calculation TA=(B)+disp (0<disp<4095) TA=(B)+disp (-2048<disp<2047)

_ When base relative mode is used, disp is a 12-bits unsigned integer _ When program-counter relative mode is used, disp is a 12-bits signed integer_ 2s complement _ Direct addressing for formats 3 and 4 if b=p=0 _ These two addressing mode can combine with index addressing if x=1 _ Bits x,b,p,e: how to calculate the target address _ relative, direct, and indexed addressing Modes _ Bits i and n: how to use the target address (TA) Mode Indication operand value Immediate addressing i=1,n=0 TA:TA is used as the Operand value Indirect addressing i=0,n=1 ((TA)):the word at TA is Fetched.value of TA is Of the operand value Standard SIC (TA):TA is taken as the address of the Operand value Taken as the address

Simple addressing i=0,n=0 I=1,n=1

_ Data formats _ There is a 48-bit floating-point data type 1 11 36

S exponent fraction _ sign bit s (0: +, 1: -) _ fraction f: a value between 0 and 1 _ exponent e: unsigned binary number between 0 and 2047 _ value: s * f * 2 (e-1024) _ Ex: 5 = 22+20=(2-1+2-3)*23= (2-1+2-3)*21027-1024 0,10000000011,1010000.0

_ Register (Additional registers) Mnemonic B S T F 5 6 Number Special use 3 Base register; used for addressing 4 General working register-no special use General working register-no special use Floating-point accumumulator(48bits)

_ Registers S and T are only for storing data. They can not use for accumulator COMPR X, T

6. Explain SIC/XE machine instruction formats and all addressing modes by clearly indicating the setting of different flag bits. INSTRUCTION FORMATS The maximum memory available on a SIC/XE system is 1 megabyte (2 power 20 bytes).This increase leads to a change in instruction formats and addressing modes. The larger memory available on SIC/XE means that an address will no longer fit into 15-bit field; thus instruction format used on the standard version of SIC is no longer suitable. There are two possible options-either use some form of relative addressing or extend the address field to 20 bits. Both of these options are included in SIC/XE.SIC/XE provides some instructions that do not reference memory at all. Format 1 and 2 in the following description are used for such instruction.

Bit e is used to distinguish between format 3 and 4(e=0 means format 3, e=1 means format 4). Format 1(1 byte) 8 op Ex:FIX opcode 0100 1100 Format 2(2 bytes) 8 op 4 R1 4 R2

Example: COMP A,S(Compare the contents of registers A and S) Opcode A S 1010 0000 0000 0100 8-bit 4-bit 4-bit A 0 0 4 object code Format 3(3 bytes) 6 1 1 1 1 1 1 op n i x

12 p

Disp

Example: LDA #3(load 3 to accumulator A) 6 1 1 1 1 1 1 12 0000 00 0 1 0 0 0 0 0000 0000 0011 Opcode n i x b p e 0 1 0 0 0 3 object code Format 4(4 bytes) 6 op 1 1 1 1 1 1 n i x 20 e

Address

Example: +JSUB RDREC(Jump to the address,1036) 6 1 1 1 1 1 1 20 0100 10 1 1 0 0 0 1 Opcode n i x b p e 4 B 1 0 1 0 ADDRESSING MODES

0000 0001 0000 0011 0110 3 6 object code

Two new addressing modes are available excluding direct and indexed addressing modes used in SIC. These are described in the following table:

MODE

INDICATION

TARGET ADDRESS TA=(B)+disp(0<=disp<=4095)

Base relative Program counter

b=1,p=0 relative b=0,p=1

TA=(PC)+disp(-2048<=disp<=2047)

For base relative addressing, the displacement field disp in a format 3 instruction is interpreted as 12-bit unsigned integer. For program counter relative addressing, this field is interpreted as a 12-bit signed integer. With negative values represented in 2s complement notation. If bits b and p are both set to 0, the disp field from the format 3 instruction is taken to be the target address. For a format 4 instruction, bits b and p are normally set to 0, and the target address is taken from the address field of the instruction. This is direct addressing. Any of these addressing modes can be combined with indexed addressing if bit x is set to 1, the term(X) is added in the target address calculation. Bits i and n in format 3 and 4 are used to specify how the target address is used. If bit i=1 and n=0, the target address itself is used as the operand value; no memory reference is performed. This is called immediate addressing. If bit i=0 and n=1, the word at the location given by the target address is fetched; the value contained in this word is then taken as the address of the operand value. This is called indirect addressing. If bits n and i are both 0 or both 1, the target address is taken as the location of the operand; we will refer to this as simple addressing. Indexing cannot be used with immediate or indirect addressing modes. SIC/XE instructions that specify neither immediate nor indirect addressing are assembled with bits n and I both set to 1.Assemblers for the standard version of SIC set the bits to 0.If bits n and i are both 0, then bits b,p,e are considered to be the part of the addressing field of the instruction. This makes instruction format 3 identical to the format used on the standard version of SIC, providing the desired compatibility.

Вам также может понравиться