Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Study the Instruction Set of a Small Instruction Set Computer (SISC) given on th

ID: 3676162 • Letter: S

Question

Study the Instruction Set of a Small Instruction Set Computer (SISC) given on the next page. This instruction set needs to be used to solve the problem given below. Please, make sure that you have watched all the posted videos and attempted the problems at the end of the videos before attempting to do this assignment.

The following SISC assembly language program adds two numbers at locations 70H and 71H, and stores the result at location 72H. Assemble the program, showing the object code and RAM addresses on the left side of the instructions:

            RAM               OBJECT                      ASSEMBLY

            ADDRESS        CODE                         INSTRUCTION

                                                                        ORG    40H                  ;Assembler directive

            40H                  04H 25H                      MOV    RA,25H

            42H                  03H 70H                      MOV    @70H,RA         ;Store 25H in location 70H

                                                                        MOV    RA,30H

                                                                        MOV    @71H,RA         ;Store 30H in location 71H

                                                                        CALL   PRO1               ;Add the two numbers

                                                                        RET                             ;Return to OS

                                                            PRO1: MOV    RA,@70H         ;Read location 70H

                                                                        MOV    RB,RA

                                                                        MOV    RA,@71H         ;Read location 71H

                                                                        ADD     RA,RB              ;Add

                                                                        MOV    @72H,RA         ;Put the result in 72H

                                                                        RET                             ;Return to the main program

Instruction Set:

The instruction set of the processor is as follows:

Bytes        Object Code             Instruction                                  Comments

1                 00H                          MOV RA,RB                               RA <---- RB

1                 01H                          MOV RB,RA                               RB <---- RA

2                 02H                          MOV RA,MEM                           RA <---- (MEM)                          ;The address MEM is the 2nd byte of the instruction

2                 03H                          MOV MEM,RA                           MEM<---- RA                              ;The address MEM is the 2nd byte of the instruction

2                 04H                          MOV RA,IMM                             RA <---- IMM                              ;The Immediate data is the 2nd byte of the instruction

1                 05H                          MOV RA,[RB]                             RA <---- MEM(RB)                    ;Move contents of memory location pointed by RB.

1                 06H                          MOV [RB],RA                             MEM(RB) <---- RA                    ;Move RA to the memory location pointed by RB.

1                 07H                          MOV RA,SP                                RA <---- SP

1                 08H                          MOV SP,RA                                SP <---- RA

1                 09H                          XCHG                                           RA <---> RB                               ;Switch the contents of RA and RB

1                 10H                          ADD RA,RB                                RA <---- RA plus RB                  ;Add without carry

1                 11H                          ADC RA,RB                                RA <---- RA plus RB plus Ci      ;Add with carry

1                 12H                          SUB RB,RA                                RB <---- RB minus RA               ;Subtract without borrow

1                 13H                          INC   RA                                       RA <---- RA plus 1

1                 14H                          DEC RA                                      RA <---- RA minus 1

1                 15H                          INC   RB                                       RB <---- RB plus 1

1                 16H                          DEC RB                                      RB <---- RB plus 1

1                 20H                          CMP RB,RA                               RB minus RA

2                 21H                          CMP RA,IMM                             RA minus IMM                            ;The second byte is the immediate data

1                 30H                          AND RA,RB                                RA <---- (RA) AND (RB)

1                 31H                          OR   RA,RB                                 RA <---- (RA) OR (RB)

1                 32H                          NEG RA                                      RA <---- NEG (RA)

2                 40H                          JZ   ADDRESS                            IP <---- ADDRESS {if Z=1}                         ;ADDRESS is the 2nd byte of the instruction

2                 41H                          JNZ ADDRESS                          IP <---- ADDRESS {if Z=0}                         ;Jump if result is not zero

2                 42H                          JS   ADDRESS                            IP <---- ADDRESS {if S=1}                         ;Jump if result is negative

2                 43H                          JGT ADDRESS                          IP <---- ADDRESS {if GT=1}                      ;Jump if ABUS is greater than BBUS (signed)

2                 44H                          JLT ADDRESS                           IP <---- ADDRESS {if LT=1}                       ;Jump if ABUS is less than BBUS (signed)

2                 45H                          JA ADDRESS                             IP <---- ADDRESS {if C=1 and Z=0}          ;Jump if ABUS is greater than BBUS (unsigned)

2                 46H                          JB ADDRESS                             IP <---- ADDRESS {if C=0}                         ;Jump if ABUS is less than BBUS (unsigned)

2                 47H                          JRDY ADDRESS                        IP <---- ADDRESS {if RDY1}                      ;Jump if RDY is 1

2                 48H                          JMP ADDRESS                         IP <---- ADDRESS                                       ;Jump to ADDRESS

2                 50H                          CALL ADDRESS                                                             ;Save the return address on stack and jump to ADDRESS

1                 51H                          CALL [RB]                                                                        ;Save the return address on stack and jump to location whose address is in RB

1                 52H                          RET                                                                                  ;Get the return address from stack and jump to this address

1                 60H                          IN ADDRESS                                                                 ;Input data from the input port, with address ADDRESS, to register RA

1                 61H                          OUT ADDRESS                                                             ;Output data to the output port, with address ADDRESS, from register RA

1                 70H                          CLC                                                                                  ;Clear the carry flip flop

1                 71H                          STC                                                                                  ;Set the carry flip flop

1                 72H                          CLRRDY                                                                          ;Clear the RDY flip flop

Explanation / Answer

Assembled program, showing the object code and RAM addresses on the left side of the instructions:

Since address of PRO label is not given so let's assume it as 100H;

Object Code 50H takes 2 bytes

RAM ADDRESS OBJECT CODE ASSEMBLY INSTRUCTION COMMENTS 40H 04H 25H MOV RA,25H Object Code 04H takes 2 bytes 42H 03H 70H MOV @70H,RA Object Code 03H takes 2 bytes 44H 04H 30H MOV RA,30H Object Code 04H takes 2 bytes 46H 03H 71H MOV @71H,RA Object Code 03H takes 2 bytes 48H 50H 100H CALL PRO

Since address of PRO label is not given so let's assume it as 100H;

Object Code 50H takes 2 bytes

50H 52H RET Object Code 52H takes 1 byte 51H Hence next address is 50+1=51H 100H 02H 70H PRO:MOV RA,@70H Object Code 02H takes 2 bytes 102H 01H MOV RB,RA Object Code 01H takes 1 byte 103H 02H 71H MOV RA,@71H Object Code 02H takes 2 bytes 105H 10H ADD RB,RA Object Code 10H takes 1 byte 106H 03H 72H MOV @72H,RA Object Code 03H takes 2 bytes 108H 52H RET Object Code 52H takes 1 byte.But here address from previous instruction (i.e. 51H) will be loaded from stack and control will be transferred to instructions present at that location onwards