Skip to content

Commit efe9da9

Browse files
committed
added internal termination instruction and added ci/cd tests for llarm-emu
1 parent f650cda commit efe9da9

20 files changed

Lines changed: 136 additions & 34 deletions

File tree

.github/workflows/llarm-emu.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- 'llarm-emu/**/CMakeLists.txt'
1111
- 'llarm-emu/**/*.cmake'
1212
- 'llarm-emu/**/*.cmake.in'
13+
- 'llarm-emu/tests/**'
1314
- 'llarm-asm/**/*.cpp'
1415
- 'llarm-asm/**/*.hpp'
1516
- 'llarm-asm/**/CMakeLists.txt'
@@ -25,6 +26,7 @@ on:
2526
- 'llarm-emu/**/CMakeLists.txt'
2627
- 'llarm-emu/**/*.cmake'
2728
- 'llarm-emu/**/*.cmake.in'
29+
- 'llarm-emu/tests/**'
2830
- 'llarm-asm/**/*.cpp'
2931
- 'llarm-asm/**/*.hpp'
3032
- 'llarm-asm/**/CMakeLists.txt'
@@ -62,6 +64,12 @@ jobs:
6264
- name: Build
6365
run: cmake --build llarm-emu/build --parallel
6466

67+
- name: Install ARM toolchain
68+
run: sudo apt-get install -y binutils-arm-none-eabi
69+
70+
- name: Run integration tests
71+
run: bash llarm-emu/tests/run_tests.sh llarm-emu/build/llarm-emu
72+
6573
- name: Install clang-tidy
6674
run: sudo apt-get install -y clang-tidy clang-tools
6775

llarm-asm/src/assemble/arm/generators.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ u32 generators::arm(const IR_arm_struct& IR) {
1313
case arm_id::UNKNOWN: return 0;
1414
case arm_id::UNDEFINED: return 0;
1515
case arm_id::NOP: return 0;
16+
case arm_id::HALT: return 0xE7FFDEAD; // custom instruction, not a real one
1617
case arm_id::ADC: return data_instruction(id, operands);
1718
case arm_id::ADD: return data_instruction(id, operands);
1819
case arm_id::AND: return data_instruction(id, operands);

llarm-asm/src/disassemble/disassemble.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ std::string disassemble::arm_generate(const u32 code, const u32 PC, const settin
324324
case arm_id::UXTB: return generators::arm::math::UXTB(code, settings);
325325
case arm_id::UXTB16: return generators::arm::math::UXTB16(code, settings);
326326
case arm_id::UXTH: return generators::arm::math::UXTH(code, settings);
327-
case arm_id::NOP: return generators::arm::misc::NOP();
327+
case arm_id::NOP: return "NOP";
328+
case arm_id::HALT: return "HALT";
328329
case arm_id::UNKNOWN: llarm::out::error("Unknown instruction encountered for disassembly");
329330
case arm_id::UNDEFINED: return UNDEFINED;
330331
break;
@@ -444,10 +445,11 @@ std::string disassemble::arm_id_to_string(const arm_id id) {
444445
switch (id) {
445446
case arm_id::UNKNOWN: return ERROR;
446447
case arm_id::UNDEFINED: return UNDEFINED;
448+
case arm_id::NOP: return "NOP";
449+
case arm_id::HALT: return "HALT";
447450
case arm_id::ADC: return "ADC";
448451
case arm_id::ADD: return "ADD";
449452
case arm_id::AND: return "AND";
450-
case arm_id::NOP: return "NOP";
451453
case arm_id::B: return "B";
452454
case arm_id::BL: return "BL";
453455
case arm_id::BIC: return "BIC";

llarm-asm/src/disassemble/generators/arm/misc.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,6 @@ std::string generators::arm::misc::SWI(const u32 code, const settings& settings)
7171
}
7272

7373

74-
/**
75-
* This isn't a real instruction documentated in the ARM docs,
76-
* but i'm still adding this here for the sake of convenience
77-
*/
78-
std::string generators::arm::misc::NOP() {
79-
return "NOP";
80-
}
81-
82-
8374
/**
8475
* CPS<effect> <iflags> {, #<mode>}
8576
* CPS #<mode>

llarm-asm/src/disassemble/generators/generators.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ namespace internal::generators {
137137
}
138138

139139
namespace misc {
140-
std::string NOP();
141140
std::string CMNP(const u32 code, const settings& settings);
142141
std::string CMPP(const u32 code, const settings& settings);
143142
std::string TEQP(const u32 code, const settings& settings);

llarm-asm/src/id/instruction_id.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace internal {
77
UNKNOWN,
88
UNDEFINED,
99
NOP,
10+
HALT,
1011

1112
// ARMv1 and 26-bit architecture instructions
1213
ADC,

llarm-asm/src/identifiers/bin_arm.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ arm_id ident::bin_arm::coproc_and_floats(const u32 code) {
852852
arm_id ident::bin_arm::arm(const u32 code) {
853853
// note: NOP is not handled because it's a pseudo
854854
// instruction that's unique to this project.
855-
855+
856856
if (llarm::util::bit_range(code, 28, 31) == 0b1111) {
857857
const arm_id tmp = unconditional(code);
858858

@@ -931,6 +931,11 @@ arm_id ident::bin_arm::arm(const u32 code) {
931931
return pack_and_saturates(code);
932932
}
933933

934+
// special instruction opcode, doesn't exist on real systems
935+
if (code == 0xE7FFDEAD) {
936+
return arm_id::HALT;
937+
}
938+
934939
// load/store register offset
935940
return load_store(code);
936941

llarm-asm/src/interpreter/mnemonic_arm.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ mnemonic_struct_arm mnemonic_arm::fetch_mnemonic_args(const arm_id id, sv mnemon
381381
case arm_id::MRC2:
382382
case arm_id::BKPT:
383383
case arm_id::NOP: // maybe this shouldn't be here since it's a unique instruction to the project, idk
384+
case arm_id::HALT: // same here
384385
case arm_id::PLD:
385386
case arm_id::SETEND:
386387
args.cond_id = cond_id::NONE;

llarm-asm/src/validation/bin_arm.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ bool validation::bin_arm::is_arm_instruction_valid(const u32 code) {
101101
case arm_id::UNKNOWN: return false;
102102
case arm_id::UNDEFINED: return false;
103103
case arm_id::NOP: return false;
104+
case arm_id::HALT: return false;
104105
case arm_id::ADC: return check_shifter(code, shifter_category::DATA);
105106
case arm_id::ADD: return check_shifter(code, shifter_category::DATA);
106107
case arm_id::RSB: return check_shifter(code, shifter_category::DATA);

llarm-asm/src/validation/string_arm.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ bool validation::string_arm::is_arm_instruction_valid(const IR_arm_struct& IR) {
2626
case arm_id::UNKNOWN: return false;
2727
case arm_id::UNDEFINED: return false;
2828
case arm_id::NOP: return false;
29+
case arm_id::HALT: return false;
2930

3031
// addressing mode 1: data processing
3132
case arm_id::ADC:

0 commit comments

Comments
 (0)