public void handledata(List<string> line, int pass) { //FIX ME not finished //This is the old code copied across it does not handle the 'dfdsfdsfds' or 1,2,3,4,5 cases //This data is now correctly sent in the lines[] data " or ' are left intact to identify with //comma seperated data will be split string command = line[1].ToUpper(); command = command.TrimStart('.'); if (codesegment == false && pass == 0) { int bytes = 0; if (command == "DW") bytes = 2; if (command == "DB" || line[1].ToUpper() == "DEFB") bytes = 1; if (command == "DS") { int size = 0; if (!int.TryParse(line[2], out size)) { domath(line[2], out size); } bytes = size; //FIX ME DETECT HERE; } if (bytes > 0) { if (currentdatalabel != "") { fixdatalabel(currentdatalabel, bytes); } return; } } if (codesegment == true && pass == 1) { byte[] data; switch (command) { case "DB": case "DEFB": //cope with delimited entry for (int pos = 2; pos < line.Count; pos++) { //Cope with string literals as byte arrays if (line[pos][0] == '\'') { string sdata = line[pos]; sdata = sdata.Substring(1, line[pos].Length - 2); //messy conversion, must be a cleaner way byte[] b = new byte[sdata.Length]; int i = 0; foreach (char c in sdata) { b[i] = (byte)c; i++; } pushbytes(b); } else { //cope with regular numbers data = new byte[1]; int idata; if (isnumber(line[pos], out idata)) { if (idata > 255) { Exception e = new Exception("Number too big for .db"); throw e; } data[0] = (byte)idata; pushbytes(data); } } } break; case "DW": data = new byte[2]; int val; if (isnumber(line[2], out val)) { data[0] = (byte)(val & 0xFF); data[1] = (byte)(val >> 8 & 0xff); pushbytes(data); } else { linkrequiredatdata d = new linkrequiredatdata(16, line[2], 0); linkrequiredat.Add(org, d); org += 2; } break; case "DS": int size = 0; if (!int.TryParse(line[2], out size)) { domath(line[2], out size); } org += size; //Not sure how useful this really is? break; } } }
public string generateplaceholder(string label, string opstring) { //Determine how many opbytes are before the nn nn Match match = Regex.Match(opstring, @"^([A-Z0-9 ]*) nn nn$"); if (match.Success) { //fix me wrong length? int length = match.Groups[1].Value.Length / 2; linkrequiredat.Add(org + length, new linkrequiredatdata(16, label.Trim(new char[] { '(', ')' }), 0)); //Console.WriteLine(String.Format("Link required at address {0:x} for label {1}",org+length,label)); return (string.Format("{0} 00 00", match.Groups[1].Value)); } //Also this only matches the JR and DJNZ cases which are offset realitive eg +/- addressing!! Match match2 = Regex.Match(opstring, @"^([A-Z0-9]*) oo$"); if (match2.Success) { //fix me wrong length? int length = match2.Groups[1].Value.Length / 2; linkrequiredatdata lrd = new linkrequiredatdata(8, label.Trim(new char[] { '(', ')' }), 0, true, org + length + 1); //FIX ME +1?? linkrequiredat.Add(org + length, lrd); //Console.WriteLine(String.Format("Link required at address {0:x} for label {1}", org + length, label)); return (string.Format("{0} 00", match2.Groups[1].Value)); } Match match3 = Regex.Match(opstring, @"^([A-Z0-9]*) nn$"); if (match3.Success) { int length = match3.Groups[1].Value.Length / 2; linkrequiredat.Add(org + length, new linkrequiredatdata(8, label.Trim(new char[] { '(', ')' }), 0)); //Console.WriteLine(String.Format("Link required at address {0:x} for label {1}", org + length, label)); return (string.Format("{0} 00", match3.Groups[1].Value)); } Exception e = new Exception("Error matching label opcodes"); throw (e); }