function res = ChangeDec2MReg(Zc,path,filename)
%ChangeDec2MReg: 将算法给的译码结果顺序值更改为MREG中的存储顺序
%   Zc:         LDPC提升值,仅支持Zc = 8n
%   path:       文件路径
%   filename:   文件名
    ACodeBlockIndex = [1	2	3	5	6	7	12	13	15	18	20	24	26];
    BCodeBlockIndex = [4	8	9	10	11	14	16	17	19	21	22	23	25];
    res = 0;
    if mod(Zc,8)
        res = -1;
        fprintf('illegal Zc(%d).\n',Zc);
        return;
    end
    CBByteLen = Zc/8;
    Data = u32DataFromFile(path,filename);
    Data = Int32ToInt8(Data);
    DotIndex = find(filename == '.');
    Afilename_mreg = [filename(1:DotIndex-1) '_Amreg' filename(DotIndex:end)];
    Bfilename_mreg = [filename(1:DotIndex-1) '_Bmreg' filename(DotIndex:end)];
    
    Data = Data(1:CBByteLen*26);
    Data = reshape(Data,CBByteLen,26);
    tmpZero = zeros(64-CBByteLen,26);
    Data = [Data;tmpZero];
    
    Afid = fopen([path Afilename_mreg],'w');
    if -1 == Afid
        fprintf('write %s filled.\n',Afilename_mreg);
        res = -1;
        return;
    end
    Bfid = fopen([path Bfilename_mreg],'w');
    if -1 == Afid
        fprintf('write %s filled.\n',Afilename_mreg);
        res = -1;
        return;
    end
    AData = Data(:,ACodeBlockIndex);
    BData = Data(:,BCodeBlockIndex);
    AData = reshape(AData,1,[]);
    BData = reshape(BData,1,[]);
    AData = Int8ToInt32(AData);
    BData = Int8ToInt32(BData);
    fprintf(Afid,'0x%08x\n',AData);
    fprintf(Bfid,'0x%08x\n',BData);
    fclose(Afid);fclose(Bfid);
end
