You are on page 1of 5

TUTORIAL UNIT I

1. Write a sequence of instructions for SIC to ALPHA equal to the product of BETA and GA A. Assu!e that ALPHA" BETA and GA A are defined as in #i$.1.%&a'. Asse!(l) Code* LDA BETA MUL GAMMA STA ALPHA : : ALPHA RESW 1 BETA RESW 1 GAMMA RESW 1 +. Write a sequence of instructions for SIC,-E to set ALPHA equal to . / BETA 0 1. Assu!e that ALPHA and BETA are defined as in #i$. 1.%&('. 2se i!!ediate addressin$ for the constants. Asse!(l) Code* LDA BETA LDS #4 MULR S,A SUB #9 STA ALPHA : ALPHA RESW 1 BETA RESW 1 %. Write SIC instructions to s3ap the 4alues of ALPHA and BETA. Asse!(l) Code* LDA ALPHA STA GAMMA LDA BETA STA ALPHA LDA GAMMA STA BETA : ALPHA RESW 1 BETA RESW 1 GAMMA RESW 1 .. Write a sequence of instructions for SIC to set ALPHA equal to the inte$er portion of BETA 5 GA A. Assu!e that ALPHA and BETA are defined as in #i$.1.%&a'.

Asse!(l) Code* LDA BETA DIV GAMMA STA ALPHA : ALPHA RESW 1 BETA RESW 1 GAMMA RESW 1 6. Write a sequence of instructions for SIC,-E to di4ide BETA () GA A" settin$ ALPHA to the inte$er portion of the quotient and 7ELTA to the re!ainder. 2se re$ister8 to8re$ister instructions to !a9e the calculation as efficient as possi(le. Asse!(l) Code* LDA BETA LDS GAMMA DIVR S, A STA ALPHA MULR S, A LDS BETA SUBR A, S STS DELTA : ALPHA RESW 1 BETA RESW 1 GAMMA RESW 1 DELTA RESW 1 :. Write a sequence of instructions for SIC,-E to di4ide BETA () GA A" settin$ ALPHA to the 4alue of the quotient" rounded to the nearest inte$er. 2se re$ister8to8 re$ister instructions to !a9e the calculation as efficient as possi(le. Asse!(l) Code* LDF BETA DIVF GAMMA FIX STA ALPHA : ALPHA RESW 1 BETA RESW 1 GAMMA RESW 1

;. Write a sequence of instructions for SIC,-E to clear a +<8()te strin$ to all (lan9s. Asse!(l) Code* LDX ZERO LOOP LDCH BLANK STCH STR1,X TIX TWENTY LT LOOP : STR1 RESW !" BLANK BYTE C # # ZERO WORD " TWENTY WORD !" =. Write a sequence of instructions for SIC,-E to clear a +<8()te strin$ to all (lan9s. 2se i!!ediate addressin$ and re$ister8to8re$ister instructions to !a9e the process as efficient as possi(le. Asse!(l) Code* LDT #!" LDX #" LOOP LDCH #" STCH STR1,X TIXR T LT LOOP : STR1 RESW !" 1. Suppose that ALPHA is an arra) of 1<< 3ords" as defined in #i$. 1.6&a'. Write a sequence of instructions for SIC to set all 1<< ele!ents of the arra) to <. Asse!(l) Code* LDA ZERO STA INDEX LOOP LDX INDEX LDA ZERO STA ALPHA, X LDA INDEX ADD THREE STA INDEX COMP K$"" TIX TWENTY LT LOOP : INDEX RESW 1 ALPHA RESW 1""

ZERO WORD " K$"" WORD 1"" THREE WORD $ 1<. Suppose that ALPHA is an arra) of 1<< 3ords" as defined in #i$. 1.6&a'. Write a sequence of instructions for SIC,-E to set all 1<< ele!ents of the arra) to <. 2se i!!ediate addressin$ and re$ister8to8re$ister instructions to !a9e the process as efficient as possi(le. Asse!(l) Code* LDS #$ LDT #$"" LDX #" LOOP LDA #" STA ALPHA, X ADDR S, X COMPR X, T LT LOOP : ALPHA RESW 1"" 11. Suppose that ALPHA and BETA are the t3o arra)s of 1<< 3ords. Another arra) of GA A ele!ents are o(tained () !ultipl)in$ the correspondin$ ALPHA ele!ent () . and addin$ the correspondin$ BETA ele!ents. Asse!(l) Code* LDS #$ LDT #$"" LDX #" ADDLOOP LDA ALPHA, X MUL #4 ADD BETA, X STA GAMMA, X ADDR S, X COMPR X, T LT ADDLOOP : ALPHA RESW 1"" BETA RESW 1"" GAMMA RESW 1"" 1+. Suppose that ALPHA is an arra) of 1<< 3ords. Write a sequence of instructions for SIC,-E to find the !a>i!u! ele!ent in the arra) and store results in A-. Asse!(l) Code*

CLOOP

NOCH

LDS #$ LDT #$"" LDX #" LDA ALPHA, X COMP MAX LT NOCH STA MAX ADDR S, X COMPR X, T LT CLOOP : ALPHA RESW 1"" MAX WORD %$!&'(

1%. Write a su(routine for SIC,-E that 3ill read a record into a (uffer. The record !a) (e an) len$th fro! 1 to 1<< ()tes. The end of record is !ar9ed 3ith a ?null@ character &ASCII code <<'. The su(routine should place the len$th of the record read into a 4aria(le na!ed LEAGTH. 2se i!!ediate addressin$ and re$ister8to8re$ister instructions to !a9e the process as efficient as possi(le. Asse!(l) Code* SUB RDREC : RDREC LDX #" LDT #1"" LDS #" RLOOP TD INDEV E) RLOOP RD INDEV COMPR A, S E) EXIT STCH BUFFER, X TIXR T LT RLOOP EXIT STX LENGTH RSUB : INDEV BYTE X #F1* LENGTH RESW 1 BUFFER RESB 1""

You might also like