Skip to main content
Engineering LibreTexts

3.8 Problems

  • Page ID
    83027
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    1. Implement a program to prompt the user for their name and age, and using 2 calls to printf, have the program output the following string on one line:

    The user name is age year old.

    Your program should substitute the name and age of in the string with the name and age the user of the program entered. For example, if the user entered “Chuck” and “62”, the program should print “The user Chuck is 62 years old.”

    2. If the references or values to be printed in a printf statement fit in a word (32 bits), up to 3 values can be printed using r1, r2, and r3 as parameters to the printf statement. The printf statement only needs to specify that it needs to print 3 values. For example, the following code fragments would print out the integers stored in r1, r2, and r3, producing “int1 = 5, int2 = 7, and int3 = 9”.

             mov r1, #5
             mov r2, #7
             mov r3, #9
             ldr r0, =print3ints
        print3ints: .asciz “int1 = %d, int2 = %d, and int3 = %d”
    

    Write the format statements to print 2 strings and an int, and 2 ints and a string, and set up the bl printf call to properly print out these strings.

    1. Implement a program that outputs the following table. The printf statements should output the name using %s and the number using %d, with each name and age stored in at a different label address. The table should be formatted using the tab (\t) characters to move to tab settings and newline (\n) to put data on a new line.
    2. For the following program, print out the address of the num and name variables in gdb. Print out the value of each variable also. Submit a screen shot of your program.
    3. Input a floating point value using %f for scanf. Print the value you entered using printf. Notethat%finputforscanfreadsafloat,buttheprintfusesadoublevalue that is stored in r1 and r1. To convert from a float (32 bits) to a double, use the command “vcvt.F64.F32 D5, S14”. This command converts the value in the float (single precision) register S14 to the double precision register pair D5 (registers S10 and 11).

    What you will learn (Chapter 4)

    In this chapter you will learn:

    1. why this chapter covers the ARM instruction set as a 3-address load and store architecture
    2. what is an Instruction Set Architecture (ISA)
    3. a 3-address architecture
    4. how to initialize registers using the mov instruction
    5. simple arithmetic and logical operations in ARM
    6. using shift operations
    7. memory access and Von Neumann vs Harvard architectures
    8. a 3-address load and store architecture
    9. how to read and write memory
    10. the different types of memory access in ARM and when to use them

    3.8 Problems is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?