You want to write a parser. To keep my answer really simple and short, I wrote a very very simple parser for you. Here is it:
// Written by 'imerso' for a StackOverflow answer
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
// Extract next substring from current pointer
// to next separator or end of string
char* NextToken(char** cmd, const char* sep)
{
    char* pStart = *cmd;
    char* pPos = strstr(*cmd, sep);
    if (!pPos)
    {
        // no more separators, return the entire string
        return *cmd;
    }
    // return from the start of the string up to the separator
    *pPos = 0;
    *cmd = pPos+1;
    return pStart;
}
// Warning: this is a very simple and minimal parser, meant only as an example,
// so be careful. It only parses the simple commands without any spaces etc.
// I suggest you to try with ADD,R1,#5 similar commands only.
// A full parser *can* be created from here, but I wanted to keep it really simple
// for the answer to be short.
int main(int argc, char* argv[])
{
    // requires the command as a parameter
    if (argc != 2)
    {
        printf("Syntax: %s ADD,R1,#5\n", argv[0]);
        return -1;
    }
    // the command will be split into these
    char token[32];
    int reg = 0;
    int lit = 0;
    // create a modificable copy of the command-line
    char cmd[64];
    strncpy(cmd, argv[1], 64);
    printf("Command-Line: %s\n", cmd);
    // scan the three command-parameters
    char* pPos = cmd;
    strncpy(token, NextToken(&pPos, ","), 32);
    reg = atoi(NextToken(&pPos, ",")+1);
    lit = atoi(NextToken(&pPos, ",")+1);
    // show
    printf("Command: %s, register: %u, literal: %u\n", token, reg, lit);
    // done.
    return 0;
}