Skip to content

Commit

Permalink
Fix . command ignore.
Browse files Browse the repository at this point in the history
Fix label as arg to ldr.
  • Loading branch information
TheTarados committed Oct 31, 2023
1 parent 829b3fd commit f130521
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions js/render_logic/armv4/armv4.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ class Armv4 extends Generic_logic {
let index = line.indexOf("]");
let prob_with_addr = false;
switch(index){
case -1: //Label (only case where no ])
prob_with_addr ||= !Object.keys(this.jmp_addr).includes(line[3])
break;
case 5://[R1] or [R1], R2, RRX or [R1], R2, LSL #2
prob_with_addr ||= ![6, 8, 10, 11].includes(line.length);
prob_with_addr ||= line.length >6 && line[6] != ",";
Expand Down Expand Up @@ -400,10 +403,9 @@ class Armv4 extends Generic_logic {


//TODO: Make this understand pre run instruction

//Remove everything between a . and a \n
//temp_code = temp_code.replace(/\..*\n/g, '\n');

temp_code = temp_code.replace( /\.(?!WORD).*\n/g, '\n');
//Replace PC with R15
temp_code = temp_code.replace(/PC/g, 'R15');

Expand Down
4 changes: 2 additions & 2 deletions js/render_logic/armv4/instructions.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,9 @@ class armv4_Memory_operator extends armv4_Operator{
let value = 0;
let arg_is_label = elements.length ==4;
let addr = arg_is_label? this.language.jmp_addr[elements[3]]: this.language.address_solver(elements);
if(elements[4] == "R15" || arg_is_label)//addr relative to PC
if(arg_is_label || elements[4] == "R15"){//addr relative to PC
value = parseInt(this.language.code[addr/4][1], 16);
else if(addr<this.language.get_register_values()[13])//addr relative to ram
}else if(addr<this.language.get_register_values()[13])//addr relative to ram
value = this.language.ram[Math.floor(addr/4)];
else//addr relative to stack
value = this.language.stack[this.language.stack_beg/4-Math.floor(addr/4)-1];
Expand Down

0 comments on commit f130521

Please sign in to comment.