fa04 | Assembly Language | C (Programming Language)

Please download to get full document.

View again

of 2
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information Report



Views: 3 | Pages: 2

Extension: PDF | Download: 0

Related documents
  ECE 375Computer Organization and Assembly Language ProgrammingWinter 2004Solutions Set #11-(a)1 bit for the indirect mode (I), 2 bits to specify one of the processor registers (Reg.), and log 2 64K = 16 bitsfor the address part (address). Therefore, we have 25 bits - 19 bits = 6 bits for the opcode => 2 6 = 64operations. Note that it is possible to incorporate more than 64 instructions. Can you think of how this canbe done?(b) Iopcode Reg. address1 6 216 (c)Since there are two bits that specify a register, we have 2 2 = 4 registers, 25 bits each.(d)MBR = 25 bits, MAR = 16 bits, and PC = 16 bits.2-Fetch CycleStep 1:MAR ←   PCStep 2:MDR ← M(MDR), PC ←   PC +1Step 3:IR ←   MDR opcode MAR ←   MDR Address Step 4:Goto Execute CycleOne straightforward way of doing this is given below:Execute CycleStep 1:MDR ←   M(MAR); Read M(Y) from memoryStep 2:AC ← MDR; Transfer M(Y) into ACStep 3:AC ← AC +1; Increment M(Y)Step 4:MDR ← AC ; Transfer M(Y)+1 into MDRStep 5:M(MAR) ← MDR, If (AC=0) Then PC ← PC + 1; Store M(Y)+1 back into memory, and; at the same time increment PC if AC =0Step 6:Goto Fetch cycle3-All values are in hex unless otherwise noted.(a) MOVR1, R3 R1 changes to 07(b) LDIR2, $F1 R2 changes to 241 10 =F1 16 Note that LDI can only load an immediate data to registers R16-R31, so this would have give an error.Nevertheless, the point of the problem is understanding what immediate value $F1 means.(c) LDR2, X+ X changes to 0007 (effective address is post-incremented)R2 changes to 04(d) LDDR1, Y+3 Effective address (0002 + 0003 = 0005)R1 changes 2D(e) ST-Y, R4  Y changes to 0001 (effective address is pre-decremented)Memory location 01 (i.e., M[01]) changes to 01(f)  ADCR2, R1 Status Register (SR) indicates FE, thus C bit is cleared (LSB).01+ 05 = 06R2 changes to 06(g) MULR2, R3 Since 1B 16 = 27 10 , 27 10 x 7 = 175 10 = AF 16 R1 changes to 00 and R0 changes AF.4-Determine the machine codes for the following instructions(a) LDIR17, $55 1110 KKKK dddd KKKKKKKK KKKK=1001 1001dddd = 0001 (note that 1 is the MSB is implied)Thus, 1110 1001 0001 1001(b) PUSH R0 1001 001d dddd 1111ddddd = 0000Thus, 1001 0010 0000 1111(c)  ADD R17, R0 0000 11rd dddd rrrrrrrrr=00000ddddd = 10001Thus, 0000 1101 0001 00005-Using AVR assembly language, write a program that determines the number of 0”s contained in the memorylocation pointed to by register X. When the program completes, the memory location pointed to by register Xshould contains 0 and the memory location pointed to by register Y should contain the count of number of 0’s. CLRR2LDIR2, 8CLRR1LDR17, XLOOP:CLC; Clear carry flagROLR17; Rotate left through carryBRCSSKIP; Slik if carry clearedINCR1SKIP:DECR2BRNELOOPST Y, R1STX, R17DONE:JMPDONE
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks