Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(8 points) Its a Trap ! Figure 5-18 shows the branch table for trap handlers and interrupt service routines.. Chpter 4 pg 121 Control: Instructions:

(8 points) Its a Trap ! Figure 5-18 shows the branch table for trap handlers and interrupt service routines.. Chpter 4 pg 121 Control: Instructions: Software Traps shows the ARCtool instruction ta

Describe in detail how the process of returning from a trap is different from returning from a subroutine:

Given the assembly code below. Write a successfully executing trap that prints out the message Its a Trap and returns to your main code.

.begin

Main .equ 0xa00

ConsoleCode .equ 0xc00

CharactorString .equ 0xf00 !Start of CharactorString in memory

BASE .equ 0x3fffc0 !Starting point of the memory mapped region

COUT .equ 0x0 !0xffff0000 Console Data Port

COSTAT .equ 0x4 !0xffff0004 Console Status Port.

TrapCode .equ 0xff000800 !Start of trap instruction code for trap #0

.org Main

addcc %r0,0,%r1 !Set PSR zero bit to observe instruction ta loading PSR values into r18

bne EndMain !Do not call trap if condition not meet

trap: ta 0

EndMain: halt !end of routine

.org ConsoleCode

console: add %r0, %r0, %r2 !Clear r2

add %r0, %r0, %r4 !Clear r4

add %r0, %r0, %r5 !Clear r5

add %r0, %r0, %r7 !Clear r7

sethi BASE, %r4 !Set r4 with the base address 0xffff0000 for Memory Map IO

ld [StringLength], %r5 !Load the charactor string length in the charactor string counter register r5

Loop: ld [%r2 + String], %r3 !Load next char into r3

dec%r5 !decrement the charactor string counter register r5

andncc %r5,0,%r7 !see if it is equal to zero

be EndConsole !stop if the charactor string counter is zero.

Wait: ldub [%r4+COSTAT], %r1

andcc %r1, 0x80, %r1

be Wait

stb %r3, [%r4+COUT] !Print to console

add %r2, 4, %r2 !increment String offset (r2)

ba Loop

EndConsole: jmpl %r15,4,%r0 !Jump back to trap code

.org CharactorString !The "It's a Trap!" string

StringLength: 0xd

String: 0x49, 0x74, 0x27, 0x73, 0x20

0x61, 0x20, 0x54, 0x52, 0x41

0x50, 0x21

.org TrapCode !Start of trap instruction code for trap #15

.end

(9 points) Write a working ARCTool assembly code that performs the C code for initializing an array:

#include

int main () {

int n[ 10 ]; /* n is an array of 10 integers */

int i;

/* initialize elements of array n to 0 */

for ( i = 0; i < 10; i++ ) {

n[ i ] = i + 100; /* set element at location i to i + 100 */

}

return 0;

}

!addresses with 10 integers. The contents will be 100, 101,

!102, ..., 109. The addresses go from 3000-3036.

!All initial values of array labeled n are 0.

!The array is filled with its final values starting at

!the highest memory address, and decrements through the loop

.begin

.org 2048

.end

(6 pts) Define the following terms and functionality of each related to Compilation/Assembly:

Linker

Loader

Static Linking:

Dyanamic Linking:

Macro Definition:

Macro Expansion:

(9 pts) Problem 6.11: Write an ARCTool routine called add_128 that:

Assume that you have the subroutine add_64 shown in Figure: 6-8 available for you to use in your main routine.

add two 128 bit numbers, using calls to the add_64 sub-routine.

The two 128-bit operands are stored in memory locations labled x and y

the result is stored in the memory location labeld z

Answer:

We need (4) 32-bit registers and a .dwb 4 space for operands and results. Add the lower 64 bits, determine if there is a carry, then add the upper 64 bits, and add in the carry if needed. ! Please include comments

.begin

.org 2048

add_128:

.end

(6 pts) Problem 4.7 Encode the following ARC instructions in binary. (Write the machine word) Show the identity of the individual bit fields, and then the entire instruction word in the hexadecimal notation. Assume label_d is 64 bytes ahead of the instruction in which it is referenced, and label_b is 0xFFFFFFFC.

sethi 0XABCD, %r12

call label_b

orc %r15, 255, %r22

be label_d

st %r25, [%r9 + 128]

srl %r8, 31, %r9

Answer:

31

30

29

28

27

26

25

24

23

22

21

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

0

31

30

29

28

27

26

25

24

23

22

21

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

0

31

30

29

28

27

26

25

24

23

22

21

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

0

31

30

29

28

27

26

25

24

23

22

21

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

0

31

30

29

28

27

26

25

24

23

22

21

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

0

31

30

29

28

27

26

25

24

23

22

21

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

0

(9 points) Write a working ARCTool assembly code that emulates the logical programming construct below:

Use the file ARCTool/examples/IOExamples/printHelloWorld.asm as an example.

Note the use of the memory mapped I/O and the flow control mechanisms.

LENGTH = 0x24!Number of characters in the character string in hex

WHILE ( LENGTH > 0 )

DO

PRINT $Message > console!Print each character to the console

LENGTH=LENGTH-1!Decrement the counter

DONE

Use the following Message

! The "Message" charactor string

Message:0x57, 0x65, 0x20, 0x41, 0x70

0x6f, 0x6c, 0x6f, 0x67, 0x69

0x73, 0x65, 0x20, 0x66, 0x6f

0x72, 0x20, 0x74, 0x68, 0x65

0x20, 0x49, 0x6e, 0x63, 0x6f

0x6e, 0x76, 0x65, 0x6e, 0x69

0x65, 0x6e, 0x63, 0x65, 0x0a

Write the message printed in the ARCTool console window:

Print your code (with comments) :

! Prints "Message" on the Console.

! The "Message" charactor string

0x6f, 0x6c, 0x6f, 0x67, 0x69

0x73, 0x65, 0x20, 0x66, 0x6f

0x72, 0x20, 0x74, 0x68, 0x65

0x20, 0x49, 0x6e, 0x63, 0x6f

0x6e, 0x76, 0x65, 0x6e, 0x69

0x65, 0x6e, 0x63, 0x65, 0x0a

(6 points) List and proved a description the ten step Power-on Self Test (POST) computer boot process listed in the book.

(7 pts) Write a working Assembly macro code labeled add2 that:

Passes in two parameters REG1 and REG2

Stores the result in REG3

In main memory stores result into memory location a.

See Section B.6

.begin

.macro add2, REG1, REG2, REG3

.endmacro

main: .org 2000

.org 0x0ffc

x: 256

y: 128

a: 0

.end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Database Technology Edbt 88 International Conference On Extending Database Technology Venice Italy March 14 18 1988 Proceedings Lncs 303

Authors: Joachim W. Schmidt ,Stefano Ceri ,Michele Missikoff

1988th Edition

3540190740, 978-3540190745

More Books

Students also viewed these Databases questions