public bool TheSame(AsmSection other) { if (other == null) return false; if (Content.Count != other.Content.Count) return false; for (var i = 0; i < Content.Count; i++) { if (Content[i] != other.Content[i]) return false; } return true; }
private static void ProcessReserveWords(AsmParser parser, AsmSection output) { var cnt = parser.CalculateExpression(); output.ReserveBytes((int)cnt * 2); }
private static void ProcessOrg(AsmParser parser, AsmSection output) { var val = parser.CalculateExpression(); output.Offset = (int)val; }
private static void ProcessDataWords(AsmParser parser, AsmSection output) { do { if (parser.IsEndOfLine) { throw new TokenException("expected data words", parser.LastReadToken); } var token = parser.PeekToken(); if (token.Type == TokenType.String) { token = parser.ReadToken(TokenType.String); foreach (var ch in token.StringValue) { output.EmitWord(ch); } } else { var val = parser.ReadUshort(); output.EmitWord(val); } if (parser.IsEndOfLine) break; var commaPreview = parser.PeekToken(); if (commaPreview.Type != TokenType.Comma) break; parser.ReadToken(TokenType.Comma); } while (true); }
private static void ProcessDataDirective(Token token, AsmParser parser, AsmSection output) { switch (token.StringValue.ToLower()) { case "db": ProcessDataBytes(parser, output); break; case "dw": ProcessDataWords(parser, output); break; case "rb": ProcessReserveBytes(parser, output); break; case "rw": ProcessReserveWords(parser, output); break; default: throw new TokenException("invalid directive " + token.StringValue, token); } }
private static void ProcessDataBytes(AsmParser parser, AsmSection output) { do { if (parser.IsEndOfLine) { throw new TokenException("expected data bytes", parser.LastReadToken); } var token = parser.PeekToken(); if (token.Type == TokenType.String) { token = parser.ReadToken(TokenType.String); foreach (var ch in token.StringValue) { if (ch > 255) { throw new TokenException("unicode character cannot be translated to byte", token); } output.EmitByte((byte)ch); } } else { var val = parser.ReadByte(); output.EmitByte(val); } if (parser.IsEndOfLine) break; var commaPreview = parser.PeekToken(); if (commaPreview.Type != TokenType.Comma) break; parser.ReadToken(TokenType.Comma); } while (true); }