| 1831 | } |
| 1832 | |
| 1833 | bool Assemble(const string& code, uint64_t addr, DataBuffer& result, string& errors) override |
| 1834 | { |
| 1835 | MYLOG("%s()\n", __func__); |
| 1836 | |
| 1837 | /* prepend directives to command the assembler's origin and endianness */ |
| 1838 | string src; |
| 1839 | char buf[1024]; |
| 1840 | snprintf(buf, sizeof(buf), ".org %" PRIx64 "\n", addr); |
| 1841 | src += string(buf); |
| 1842 | snprintf(buf, sizeof(buf), ".endian %s\n", (endian == BigEndian) ? "big" : "little"); |
| 1843 | src += string(buf); |
| 1844 | src += code; |
| 1845 | |
| 1846 | /* assemble */ |
| 1847 | vector<uint8_t> byteEncoding; |
| 1848 | if(assemble_multiline(src, byteEncoding, errors)) { |
| 1849 | MYLOG("assemble_multiline() failed, errors contains: %s\n", errors.c_str()); |
| 1850 | return false; |
| 1851 | } |
| 1852 | |
| 1853 | result.Clear(); |
| 1854 | //for(int i=0; i<byteEncoding.size(); ++i) |
| 1855 | result.Append(&(byteEncoding[0]), byteEncoding.size()); |
| 1856 | return true; |
| 1857 | } |
| 1858 | |
| 1859 | /*************************************************************************/ |
| 1860 |
nothing calls this directly
no test coverage detected