lease Modify this code according to this instructions   cmds.c   – Need to modify the Cmd struct to include:   “ms” and “h”   – Add code in mem_display

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

plese modify the code according to the instruction in c programming 

Please Modify this code according to this instructions

 

cmds.c

 

– Need to modify the Cmd struct to include:

 

“ms” and “h”

 

– Add code in mem_display(), help(), mem_set() functions

 

– Command routine calls with 2 arguments, e.g.

 

  • mem_display(Cmd *cp, char *arguments)

 

&cmds[0]

 

Address of the string “10000”

 

– If we enter a command “md 10000” to display the contents of 16 locations starting with 10000, the arguments passed are:

 

 

 

file:     cmds.c

 

/* the Makefile arranges that #include <..> searches in the right

   places for these headers-- 200920*/

 

#include <stdio.h>

#include "slex.h"

/*===================================================================*

*

*   Command table for tutor program -- an array of structures of type

*   cmd -- for each command provide the token, the function to call when

*   that token is found, and the help message.

*

*   slex.h contains the typdef for struct cmd, and declares the

*   cmds array as extern to all the other parts of the program.

*   Code in slex.c parses user input command line and calls the

*   requested semantic action, passing a pointer to the cmd struct

*   and any arguments the user may have entered.

*

*===================================================================*/

 

PROTOTYPE int stop(Cmd *cp, char *arguments);

PROTOTYPE int mem_display(Cmd *cp, char *arguments);

 

/* command table */

 

Cmd cmds[] = {{"md",  mem_display, "Memory display: MD <addr>"},

              {"s",   stop,        "Stop" },

              {NULLNULL,        NULL}};  /* null cmd to flag end of table */

 

char xyz = 6;  /* test global variable  */

char *pxyz = &xyz;  /* test pointer to xyz */

/*===================================================================*

*               command                 routines

*

*   Each command routine is called with 2 args, the remaining

*   part of the line to parse and a pointer to the struct cmd for this

*   command. Each returns 0 for continue or 1 for all-done.

*

*===================================================================*/

 

int stop(Cmd *cp, char *arguments)

{

  return 1;                     /* all done flag */

}

 

 

 

/*===================================================================*

*

*   mem_display: display contents of 16 bytes in hex

*

*/

 

int mem_display(Cmd *cp, char *arguments)

{

  printf("Reached mem_display, passed argument string: |%s|\n", arguments);

  printf("        help message: %s\n", cp->help);

  return 0;                     /* not done */

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education