* func parseDataInstruction(operands string) (Instruction, error) { arguments := DATA_EXTRACTOR.FindStringSubmatch(operands) if len(arguments) != 4 { return nil, fmt.Errorf("could not parse the arguments correctly out of DATA %s", operands) } var register REGISTER if v, ok := REGISTERS[argum
(operands string)
| 300 | */ |
| 301 | |
| 302 | func parseDataInstruction(operands string) (Instruction, error) { |
| 303 | arguments := DATA_EXTRACTOR.FindStringSubmatch(operands) |
| 304 | if len(arguments) != 6 { |
| 305 | return nil, fmt.Errorf("could not parse the arguments correctly out of DATA %s", operands) |
| 306 | } |
| 307 | |
| 308 | var register REGISTER |
| 309 | if v, ok := REGISTERS[arguments[1]]; !ok { |
| 310 | return nil, fmt.Errorf("Unknown register %s for DATA instruction", arguments[1]) |
| 311 | } else { |
| 312 | register = v |
| 313 | } |
| 314 | |
| 315 | if arguments[4] == "%" { |
| 316 | return DATA{register, SYMBOL{arguments[5]}}, nil |
| 317 | } else { |
| 318 | var value uint64 |
| 319 | var err error |
| 320 | // parse in base 16 or 10 |
| 321 | if arguments[3] == "0x" { |
| 322 | value, err = strconv.ParseUint(strings.Replace(arguments[2], "0x", "", -1), 16, 16) |
| 323 | } else { |
| 324 | value, err = strconv.ParseUint(arguments[2], 10, 16) |
| 325 | } |
| 326 | |
| 327 | if err != nil { |
| 328 | return nil, err |
| 329 | } |
| 330 | |
| 331 | return DATA{register, NUMBER{uint16(value)}}, nil |
| 332 | } |
| 333 | |
| 334 | } |