Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hi thats the complete question.Can you please let me what type information do you want? Problems 1) Complete the microcode for the basic instruction set

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
hi thats the complete question.Can you please let me what type information do you want?
Problems 1) Complete the microcode for the basic instruction set in the file b.sm. Test your microcode by entering on the command line micro b.sm basic btest.a sim btest.e Prefix these commands with "./" on a Linux, Mac OS X, or Raspbian system. Hand in listings of your b.sm file and the ".log" file created by the sim program. Assembling and Using Microcode micro b.sm (on Windows) or ./micro b.sm (on Linux, Mac OS X, or Raspbian) Symbolic microcode file: b.sm Binary microcode file: b.m List file: b.lst basic btestia (on Windows) or -/basic btest.a (on Linux, Mac OS X, or Raspbian) Or sim btest.e (on Windows) sim btest.e (on Linux, Mac OS X, or Raspbian) You should see on the screen the following (which sim also writes the to the file btest.log): Microlevel Simulator Version 1.0 Copyright (9) 2019 by Anthony J. Dos Reis Opening machine code file btest.e Using microcode for Opening microcode file b.m basic instruction sel Opening log file btest.log e output 12345678910 correct if 1 to 10 displayed MHHLER SHAN te/content/file?cmd=view&content id=13278756_1&course_id=2148076_1 60 / 99 89% + OU Show SCHOLARSCICCIUGHTONOWIng (WmIUNI SO WESLIG LO LG Le OLES103) Microlevel Simulator Version 1.0 Copyright (c) 2019 by Anthony ]. Dos Reis Opening machine code file btest.e Using microcode for Opening microcode tile b.m basic instruction set Opening log file btest.log - output 12345678910 Correct if 1 to 10 displayed ==|||| Machine code size: 52 (dec) Machine instructions executed: 47 (dec) Microcode size: 71 (dec) Microinstructions executed: 276 (dec) Load point: @ (hex) W Chapter 7 Mimpmgramming the Rasie instruction Ser 61 Debugging Microcode sim btest.e! Hit Enter key @: a.pc C.mar mar - 2000/0000 Enter to go, to step, t to off/on trace, benum>, q to quit: 1: a.pc add b.1 c.pcrd PC - 8000/0001 read machine inst 8029 from loco nzcveeee Enter to go, to step, t to off/on trace, benum>, a to quit: 2 2: a.mdr add be c.ir cond-neg addr-7 ir = 8000/8029 nzcv 1000 Execute 2 7: a.ir sll b.1 c.de condeneg addree microinstructions dc-eeee/e952 at a time nzcv 8010 Enter to go, num> to step, t to off/on trace, benum>, q to quit: q The trace shows the before after contents of registers in the register bank and the after contents of the n, 2. c. and flag registers. For example, in = Be0e/8029 nzcv 1880 Compiling C Code to the Basic Instruction Set // global variable // return the sum of of x and y 60 1 // e8701.c 2 #include 3 int s; 4 int sum(int x, int y) 5{ 6 return x + y; 7) 8 int main() 9 { 10 $ - sum(5, 7); 11 printf("%d ", s); 12 return ; 13) // call sum passing it 2 and 3 // return to startup code ho asp -1 ldi 7 ; decrement sp by adding -1 to it ; load ac with 7 ; store ac at relative address @ 61 stre Important observation: The calling sequence in the calling function creates the parameters in the called function by pushing the values of the arguments in the call onto the stack. On entry into the sum funetion, the stack looks like this: sp retaddr 3 This is the parameter X This is the parametery 62 Tot addr Idr 1 load . 10:5 60 Idr 1 addr 2 load x add y asp 2 ; pop x and y parameters main then stores the value returned by sum that is in the ac register into the global variables: st s ; assign the returned value to s Next, main displays the value in s with a dout instruction, and moves the cursor to the next line (the C program does this by calling the C library function printf, but we will simply use a dout, nl sequence): ; load ac from s 61 id s 62 dout nl Chapter 7: Microprogramming the Basic Instruction Ser 63 ; display value in s ; move cursor to next line Here is the assembly language code for the entire program, including startup code: call main halt : pushes return address 1 e8781.a 2 startup 3 4 5s 6 Sun 7. Fille ldr 1 addr 2 global variable :load x : add y 63 10:59 60 4 ; 5 s 6 sum fille idr 1 addr 2 ret global variable load x add y ; return with sum in ac asp -1 ldi 7 stro 7 8 9 HR 10 main 11 12 13 14 15 16 17 18 19 asp -1 Idi 5 stre call sum 5 decrement sp by adding -1 ; load ac with 7 ; store ac at rel addr @ decrement sp by adding -1 ; load ac with 5 ; store ac at rel addr ; pushes return address ; pop X and y parameters ; store value returned into s i load ac from ; display value in s ; move cursor to next line ; load ac with @ ; return to startup code asp 2 st s ld s dout nl 21 22 23 ldi e ret 2 inty: 1 // e07e2.c 2 #include 3 void f(int x) 4 { 5 // local variable created here 6 y = x; 7 printf("%d ", y): 8) y local variable destroyed here 9 int main() 10 11 f(3); V parameter x created here before call, destroyed after call 12 return; 13) 53 10:55 PM 64 Chapter 7: Microprogramming the Basic Instruction Ser ; pushes return address ESEMBRES ; create local variable y ; get x ; store into y Local variable y ; get y created and destroyed ; display y by called function 1 ; e0702.a 2 startup call main 3 halt 4 ; ---- 5 f. asp -1 6 Idr 2 7 str @ 8 ldr @ 9 dout 10 nl 11 12 ret 13 ; ===== 14 main asp -1 15 ldi 3 16 stro 17 call f 18 asp 1 19 ldi 20 ret asp 1 ; destroy y ; return to main DN $ create x on the stack get 3 Parameter x created ; store 3 into X and destroyed by ; destroy x calling function ; return to startup code Problems 1rentet them thuhe intrat in the file hcm Tact mentorine 15 to step, t to off/on trace, benum>, q to quit: 1: a.pc add b.1 c.pcrd PC - 8000/0001 read machine inst 8029 from loco nzcveeee Enter to go, to step, t to off/on trace, benum>, a to quit: 2 2: a.mdr add be c.ir cond-neg addr-7 ir = 8000/8029 nzcv 1000 Execute 2 7: a.ir sll b.1 c.de condeneg addree microinstructions dc-eeee/e952 at a time nzcv 8010 Enter to go, num> to step, t to off/on trace, benum>, q to quit: q The trace shows the before after contents of registers in the register bank and the after contents of the n, 2. c. and flag registers. For example, in = Be0e/8029 nzcv 1880 Compiling C Code to the Basic Instruction Set // global variable // return the sum of of x and y 60 1 // e8701.c 2 #include 3 int s; 4 int sum(int x, int y) 5{ 6 return x + y; 7) 8 int main() 9 { 10 $ - sum(5, 7); 11 printf("%d ", s); 12 return ; 13) // call sum passing it 2 and 3 // return to startup code ho asp -1 ldi 7 ; decrement sp by adding -1 to it ; load ac with 7 ; store ac at relative address @ 61 stre Important observation: The calling sequence in the calling function creates the parameters in the called function by pushing the values of the arguments in the call onto the stack. On entry into the sum funetion, the stack looks like this: sp retaddr 3 This is the parameter X This is the parametery 62 Tot addr Idr 1 load . 10:5 60 Idr 1 addr 2 load x add y asp 2 ; pop x and y parameters main then stores the value returned by sum that is in the ac register into the global variables: st s ; assign the returned value to s Next, main displays the value in s with a dout instruction, and moves the cursor to the next line (the C program does this by calling the C library function printf, but we will simply use a dout, nl sequence): ; load ac from s 61 id s 62 dout nl Chapter 7: Microprogramming the Basic Instruction Ser 63 ; display value in s ; move cursor to next line Here is the assembly language code for the entire program, including startup code: call main halt : pushes return address 1 e8781.a 2 startup 3 4 5s 6 Sun 7. Fille ldr 1 addr 2 global variable :load x : add y 63 10:59 60 4 ; 5 s 6 sum fille idr 1 addr 2 ret global variable load x add y ; return with sum in ac asp -1 ldi 7 stro 7 8 9 HR 10 main 11 12 13 14 15 16 17 18 19 asp -1 Idi 5 stre call sum 5 decrement sp by adding -1 ; load ac with 7 ; store ac at rel addr @ decrement sp by adding -1 ; load ac with 5 ; store ac at rel addr ; pushes return address ; pop X and y parameters ; store value returned into s i load ac from ; display value in s ; move cursor to next line ; load ac with @ ; return to startup code asp 2 st s ld s dout nl 21 22 23 ldi e ret 2 inty: 1 // e07e2.c 2 #include 3 void f(int x) 4 { 5 // local variable created here 6 y = x; 7 printf("%d ", y): 8) y local variable destroyed here 9 int main() 10 11 f(3); V parameter x created here before call, destroyed after call 12 return; 13) 53 10:55 PM 64 Chapter 7: Microprogramming the Basic Instruction Ser ; pushes return address ESEMBRES ; create local variable y ; get x ; store into y Local variable y ; get y created and destroyed ; display y by called function 1 ; e0702.a 2 startup call main 3 halt 4 ; ---- 5 f. asp -1 6 Idr 2 7 str @ 8 ldr @ 9 dout 10 nl 11 12 ret 13 ; ===== 14 main asp -1 15 ldi 3 16 stro 17 call f 18 asp 1 19 ldi 20 ret asp 1 ; destroy y ; return to main DN $ create x on the stack get 3 Parameter x created ; store 3 into X and destroyed by ; destroy x calling function ; return to startup code Problems 1rentet them thuhe intrat in the file hcm Tact mentorine 15

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

Students also viewed these Databases questions