当前位置: 首页>>代码示例>>C#>>正文


C# CGenState.MOVW方法代码示例

本文整理汇总了C#中CodeGeneration.CGenState.MOVW方法的典型用法代码示例。如果您正苦于以下问题:C# CGenState.MOVW方法的具体用法?C# CGenState.MOVW怎么用?C# CGenState.MOVW使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CodeGeneration.CGenState的用法示例。


在下文中一共展示了CGenState.MOVW方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CGenDecln


//.........这里部分代码省略.........
                        last = offset + expr.Type.SizeOf;
                    });

                } else {

                    // Global without initialization.

                    switch (this.scs) {
                        case StorageClass.AUTO:
                            // .comm name,size,align
                            break;

                        case StorageClass.EXTERN:
                            break;

                        case StorageClass.STATIC:
                            // .local name
                            // .comm name,size,align
                            state.LOCAL(this.name);
                            break;

                        case StorageClass.TYPEDEF:
                            // Ignore.
                            return;

                        default:
                            throw new InvalidProgramException();
                    }

                    if (this.type.Kind != ExprTypeKind.FUNCTION) {
                        state.COMM(this.name, this.type.SizeOf, ExprType.ALIGN_LONG);
                    }

                    
                }

                state.NEWLINE();

            } else {
                // stack object

                state.CGenExpandStackTo(env.StackSize, ToString());

                Int32 stack_size = env.StackSize;

                // pos should be equal to stack_size, but whatever...
                Int32 pos = env.Find(this.name).Value.Offset;
                if (this.initr.IsNone) {
                    return;
                }

                Initr initr = this.initr.Value;
                initr.Iterate(this.type, (Int32 offset, Expr expr) => {
                    Reg ret = expr.CGenValue(state);
                    switch (expr.Type.Kind) {
                        case ExprTypeKind.CHAR:
                        case ExprTypeKind.UCHAR:
                            state.MOVB(Reg.EAX, pos + offset, Reg.EBP);
                            break;

                        case ExprTypeKind.SHORT:
                        case ExprTypeKind.USHORT:
                            state.MOVW(Reg.EAX, pos + offset, Reg.EBP);
                            break;

                        case ExprTypeKind.DOUBLE:
                            state.FSTPL(pos + offset, Reg.EBP);
                            break;

                        case ExprTypeKind.FLOAT:
                            state.FSTPS(pos + offset, Reg.EBP);
                            break;

                        case ExprTypeKind.LONG:
                        case ExprTypeKind.ULONG:
                        case ExprTypeKind.POINTER:
                            state.MOVL(Reg.EAX, pos + offset, Reg.EBP);
                            break;

                        case ExprTypeKind.STRUCT_OR_UNION:
                            state.MOVL(Reg.EAX, Reg.ESI);
                            state.LEA(pos + offset, Reg.EBP, Reg.EDI);
                            state.MOVL(expr.Type.SizeOf, Reg.ECX);
                            state.CGenMemCpy();
                            break;

                        case ExprTypeKind.ARRAY:
                        case ExprTypeKind.FUNCTION:
                            throw new InvalidProgramException($"How could a {expr.Type.Kind} be in a init list?");

                        default:
                            throw new InvalidProgramException();
                    }

                    state.CGenForceStackSizeTo(stack_size);

                });

            } // stack object
        }
开发者ID:phisiart,项目名称:C-Compiler,代码行数:101,代码来源:Declarations.cs

示例2: CalcAndSaveWord

 public override void CalcAndSaveWord(CGenState state) {
     state.ADDL(1, Reg.EBX);
     state.MOVW(Reg.BX, 0, Reg.ECX);
 }
开发者ID:phisiart,项目名称:C-Compiler,代码行数:4,代码来源:UnaryOperators.cs

示例3: CGenValue

        public override Reg CGenValue(CGenState state) {
            // 1. %eax = &left
            this.Left.CGenAddress(state);

            // 2. push %eax
            Int32 pos = state.CGenPushLong(Reg.EAX);

            Reg ret = this.Right.CGenValue(state);
            switch (this.Left.Type.Kind) {
                case ExprTypeKind.CHAR:
                case ExprTypeKind.UCHAR:
                    // pop %ebx
                    // now %ebx = %Left
                    state.CGenPopLong(pos, Reg.EBX);

                    // *%ebx = %al
                    state.MOVB(Reg.AL, 0, Reg.EBX);

                    return Reg.EAX;

                case ExprTypeKind.SHORT:
                case ExprTypeKind.USHORT:
                    // pop %ebx
                    // now %ebx = %Left
                    state.CGenPopLong(pos, Reg.EBX);

                    // *%ebx = %al
                    state.MOVW(Reg.AX, 0, Reg.EBX);

                    return Reg.EAX;

                case ExprTypeKind.LONG:
                case ExprTypeKind.ULONG:
                case ExprTypeKind.POINTER:
                    // pop %ebx
                    // now %ebx = &Left
                    state.CGenPopLong(pos, Reg.EBX);

                    // *%ebx = %al
                    state.MOVL(Reg.EAX, 0, Reg.EBX);

                    return Reg.EAX;

                case ExprTypeKind.FLOAT:
                    // pop %ebx
                    // now %ebx = &Left
                    state.CGenPopLong(pos, Reg.EBX);

                    // *%ebx = %st(0)
                    state.FSTS(0, Reg.EBX);

                    return Reg.ST0;

                case ExprTypeKind.DOUBLE:
                    // pop %ebx
                    // now %ebx = &Left
                    state.CGenPopLong(pos, Reg.EBX);

                    // *%ebx = %st(0)
                    state.FSTL(0, Reg.EBX);

                    return Reg.ST0;

                case ExprTypeKind.STRUCT_OR_UNION:
                    // pop %edi
                    // now %edi = &Left
                    state.CGenPopLong(pos, Reg.EDI);

                    // %esi = &Right
                    state.MOVL(Reg.EAX, Reg.ESI);

                    // %ecx = nbytes
                    state.MOVL(this.Left.Type.SizeOf, Reg.ECX);

                    state.CGenMemCpy();

                    // %eax = &Left
                    state.MOVL(Reg.EDI, Reg.EAX);

                    return Reg.EAX;

                case ExprTypeKind.FUNCTION:
                case ExprTypeKind.VOID:
                case ExprTypeKind.ARRAY:
                case ExprTypeKind.INCOMPLETE_ARRAY:
                default:
                    throw new InvalidProgramException("cannot assign to a " + this.Type.Kind);
            }
        }
开发者ID:phisiart,项目名称:C-Compiler,代码行数:89,代码来源:Expressions.cs


注:本文中的CodeGeneration.CGenState.MOVW方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。