SHOW YOUR WORK and WRITE NEATLY !!!
Note: For the programming problems on this quiz:
* You do not need to comment your code (though it may help
for partial credit if you make an error)
* You do not need to prompt the user
1. Write an assembly language program which swaps the values
in registers R8 and R9.
2. Write an assembly language program which loads register
RD with the smallest of the values stored in registers RA, RB, and RC.
3. Write an assembly language program which loads register
R3 with 0x01 if the value in register R4 is odd, and 0x00 otherwise. (Hint:
in all odd numbers the rightmost bit is set to 1 -- you may want to use
an and operator to select that bit)
4. Consider the following assembly language program:
load R1,0x01 ;; 0x01 = 1
load R2,0x19 ;; 0x19 = 25
load R5,0x41 ;; 0x41 = 65 = ASCII('A')
move R0,R5
addi R0,R0,R2
DoMore:
move RF,R5
addi R5,R5,R1
jmpLE R5<=R0,DoMore
haltState very clearly, in as few words as possible, precisely what this program does.
5. When the program in problem 4 is assembled (loaded into
SimpSim), how many bytes will the resulting machine language program take
up? Very briefly explain.
6. True or False:
a) The Arithmetic Logic Unit, or ALU, includes a Program Counter and an Instruction Register, and communicates with the CPU across the bus.See Course Home Page.b) It is possible to write the game of Nim in assembly language.
c) It is possible to write any computer game (even chess!), and any computer program (even a word processor or a web browser!) in assembly language.
d) Assembly language depends on the kind of chip in a computer, so PC's using Intel chips (such as the Pentium) do not use the same assembly language as Macs using Motorola chips.