Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 69 additions & 8 deletions components/simulator/creator_uielto_memory_stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
var uielto_memory_stack = {

props: {
unallocated_memory: { type: Array, required: true },
memory: { type: Array, required: true }
},

Expand All @@ -36,6 +35,11 @@
},

methods: {
/*Filter table instructions*/
filter(row, filter){
return (Math.abs(row.Address - app._data.end_callee) < 40);
},

select_stack_type(record, index){
app._data.row_index = index; //TODO: vue bidirectional updates
app.$refs['stack_modal'].show(); //TODO: vue bidirectional updates
Expand All @@ -47,8 +51,10 @@
' striped ' +
' small ' +
' hover ' +
' :items="unallocated_memory.concat(Object.values(memory)[2])" ' +
' :items="memory" ' +
' :fields="memFields" ' +
' :filter-function=filter ' +
' filter=" " ' +
' class="memory_table" ' +
' @row-clicked="select_stack_type">' +
' ' +
Expand All @@ -73,16 +79,19 @@
' </template>' +
' ' +
' <template v-slot:cell(Address)="row">' +
' <span class="h6Sm text-secondary" v-if="row.item.unallocated==true">' +
' <span class="h6Sm text-secondary" v-if="((row.item.Address < app._data.end_callee) && (Math.abs(row.item.Address - app._data.end_callee) < 40))">' + //Llamado
' 0x{{((row.item.Address + 3).toString(16)).padStart(row.item.Address.length-2, "0").toUpperCase()}} - 0x{{(row.item.Address.toString(16)).padStart(row.item.Address.length-2, "0").toUpperCase()}}' +
' </span>' +
' <span class="h6Sm text-success" v-if="((row.item.Address < app._data.begin_callee) && (row.item.Address >= app._data.end_callee))">' + //Llamante
' 0x{{((row.item.Address + 3).toString(16)).padStart(row.item.Address.length-2, "0").toUpperCase()}} - 0x{{(row.item.Address.toString(16)).padStart(row.item.Address.length-2, "0").toUpperCase()}}' +
' </span>' +
' <span class="h6Sm" v-if="row.item.unallocated==false">' +
' <span class="h6Sm" v-if="(row.item.Address >= app._data.begin_callee)">' + //Antes del llamante
' 0x{{((row.item.Address + 3).toString(16)).padStart(row.item.Address.length-2, "0").toUpperCase()}} - 0x{{(row.item.Address.toString(16)).padStart(row.item.Address.length-2, "0").toUpperCase()}}' +
' </span>' +
' </template>' +
' ' +
' <template v-slot:cell(Binary)="row">' +
' <span class="h6Sm text-secondary" v-if="row.item.unallocated==true">' +
' <span class="h6Sm text-secondary" v-if="((row.item.Address < app._data.end_callee) && (Math.abs(row.item.Address - app._data.end_callee) < 40))">' + //Llamado
' <span class="memoryBorder" v-if="row.item.Binary[3].Tag != null">' +
' {{row.item.Binary[3].Bin.toUpperCase()}}' +
' </span> ' +
Expand Down Expand Up @@ -132,7 +141,7 @@
' </b-badge>' +
' </span>' +
' ' +
' <span class="h6Sm" v-if="row.item.unallocated==false">' +
' <span class="h6Sm text-success" v-if="((row.item.Address < app._data.begin_callee) && (row.item.Address >= app._data.end_callee))">' +
' <span class="memoryBorder" v-if="row.item.Binary[3].Tag != null">' +
' {{row.item.Binary[3].Bin.toUpperCase()}}' +
' </span> ' +
Expand Down Expand Up @@ -181,10 +190,62 @@
' {{row.item.Binary[0].Tag}}' +
' </b-badge>' +
' </span>' +
' ' +
' <span class="h6Sm" v-if="(row.item.Address >= app._data.begin_callee)">' + //Antes del llamante
' <span class="memoryBorder" v-if="row.item.Binary[3].Tag != null">' +
' {{row.item.Binary[3].Bin.toUpperCase()}}' +
' </span> ' +
' <span v-if="row.item.Binary[3].Tag == null">' +
' {{row.item.Binary[3].Bin.toUpperCase()}}' +
' </span> ' +
' <b-badge pill variant="info" ' +
' class="border border-info shadow binaryTag" ' +
' v-if="row.item.Binary[3].Tag != null">' +
' {{row.item.Binary[3].Tag}}' +
' </b-badge>' +
' ' +
' <span class="memoryBorder" v-if="row.item.Binary[2].Tag != null">' +
' {{row.item.Binary[2].Bin.toUpperCase()}' +
' </span> ' +
' <span v-if="row.item.Binary[2].Tag == null">' +
' {{row.item.Binary[2].Bin.toUpperCase()}}' +
' </span> ' +
' <b-badge pill variant="info" ' +
' class="border border-info shadow binaryTag" ' +
' v-if="row.item.Binary[1].Tag != null">' +
' {{row.item.Binary[2].Tag}}' +
' </b-badge>' +
' ' +
' <span class="memoryBorder" v-if="row.item.Binary[1].Tag != null">' +
' {{row.item.Binary[1].Bin.toUpperCase()}}' +
' </span> ' +
' <span v-if="row.item.Binary[1].Tag == null">' +
' {{row.item.Binary[1].Bin.toUpperCase()}}' +
' </span> ' +
' <b-badge pill variant="info" ' +
' class="border border-info shadow binaryTag" ' +
' v-if="row.item.Binary[1].Tag != null">' +
' {{row.item.Binary[1].Tag}}' +
' </b-badge>' +
' ' +
' <span class="memoryBorder" v-if="row.item.Binary[0].Tag != null">' +
' {{row.item.Binary[0].Bin.toUpperCase()}}' +
' </span> ' +
' <span v-if="row.item.Binary[0].Tag == null">' +
' {{row.item.Binary[0].Bin.toUpperCase()}}' +
' </span>' +
' <b-badge pill variant="info" ' +
' class="border border-info shadow binaryTag" ' +
' v-if="row.item.Binary[0].Tag != null">' +
' {{row.item.Binary[0].Tag}}' +
' </b-badge>' +
' </span>' +
' ' +
' </template>' +
' <template v-slot:cell(Value)="row">' +
' <span class="h6Sm text-secondary" v-if="row.item.unallocated==true">{{row.item.Value}}</span>' +
' <span class="h6Sm" v-if="row.item.unallocated==false">{{row.item.Value}}</span>' +
' <span class="h6Sm text-secondary" v-if="((row.item.Address < app._data.end_callee) && (Math.abs(row.item.Address - app._data.end_callee) < 40))">{{row.item.Value}}</span>' +
' <span class="h6Sm text-success" v-if="((row.item.Address < app._data.begin_callee) && (row.item.Address >= app._data.end_callee))">{{row.item.Value}}</span>' +
' <span class="h6Sm" v-if="(row.item.Address >= app._data.begin_callee)">{{row.item.Value}}</span>' +
' </template>' +
' </b-table>' +
' </div>'
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3883,7 +3883,7 @@
<!-- Stack memory -->
<b-tab title="Stack">

<table-mem-stack :unallocated_memory="unallocated_memory" :memory="memory"></table-mem-stack>
<table-mem-stack :memory="memory[memory_hash[2]]"></table-mem-stack>

<!--TODO: try to include in a component this modal-->
<b-modal ref="stack_modal"
Expand Down
9 changes: 7 additions & 2 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,16 @@ try
selected_space_view: null, //TODO: try to include in a component
selected_stack_view: null, //TODO: try to include in a component
/*Memory*/
memory_hash: ["data_memory", "instructions_memory", "stack_memory"],
memory: memory,
unallocated_memory: unallocated_memory,


unallocated_memory: unallocated_memory, //TODO: delete

stack_pointer: 0,
begin_caller: 0,
end_caller: 0,
begin_callee: 0,
end_callee: 0,



Expand Down
3 changes: 3 additions & 0 deletions js/creator_definition_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
* Description API
*/

var caller_stack = [];


function check_protection_jal () // TODO: update the name to a proper one :-)
{
var function_name = "main"; // TODO: get current subrutine name
Expand Down
18 changes: 11 additions & 7 deletions js/creator_executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1656,28 +1656,28 @@ function writeStackLimit ( stackLimit )
throw packExecute(true, 'Segmentation fault. You tried to read in the text segment', 'danger', null);
}
else{
if(stackLimit < architecture.memory_layout[4].value){
//if(stackLimit < architecture.memory_layout[4].value){
var diff = architecture.memory_layout[4].value - stackLimit;
var auxStackLimit = stackLimit;
var newRow = 0;

for (var i = 0; i < (diff/4); i++){
if(unallocated_memory.length > 0){
/*if(unallocated_memory.length > 0){
memory[memory_hash[2]].splice(0, 0, unallocated_memory[unallocated_memory.length-1]);
memory[memory_hash[2]][0].unallocated = false;
unallocated_memory.splice(unallocated_memory.length-1, 1);
}
else{
else{*/
memory[memory_hash[2]].splice(newRow, 0,{Address: auxStackLimit, Binary: [], Value: null, DefValue: null, reset: true, unallocated: false});
for (var z = 0; z < 4; z++){
(memory[memory_hash[2]][newRow].Binary).push({Addr: auxStackLimit, DefBin: "00", Bin: "00", Tag: null},);
auxStackLimit++;
}
newRow++;
}
//}
}
}
else if(stackLimit > architecture.memory_layout[4].value){
//}
/*else if(stackLimit > architecture.memory_layout[4].value){
var diff = stackLimit - architecture.memory_layout[4].value;
for (var i = 0; i < (diff/4); i++){
unallocated_memory.push(memory[memory_hash[2]][0]);
Expand All @@ -1689,7 +1689,9 @@ function writeStackLimit ( stackLimit )
unallocated_memory.splice(0, 15);
}
}
}
}*/

creator_callstack_setsp(stackLimit);

architecture.memory_layout[4].value = stackLimit;

Expand Down Expand Up @@ -2321,6 +2323,8 @@ function syscall ( action, indexComp, indexElem, indexComp2, indexElem2, first_t
if (typeof app !== "undefined")
app._data.unallocated_memory = unallocated_memory;

creator_callstack_reset();

return true ;
}

Expand Down
66 changes: 64 additions & 2 deletions js/creator_protection_register.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
[
{
function_name: "",
begin_caller: 0,
end_caller: 0,
begin_callee: 0,
end_callee: 0,
registers_modified: [ indexComp: [ false, ... ]... ; // once per register: not modified
registers_saved: [ indexComp: [ false, ... ]... ; // once per register: saved on stack
registers_value: [ indexComp: [ 0x0, ... ], ... ; // once per register: initial value (before save)
Expand Down Expand Up @@ -97,9 +101,20 @@ function creator_callstack_enter(function_name)
}
}

if (typeof window !== "undefined"){
app._data.begin_caller = architecture.memory_layout[4].value;
app._data.end_caller = architecture.memory_layout[4].value;
app._data.begin_callee = architecture.memory_layout[4].value;
app._data.end_callee = architecture.memory_layout[4].value;
}

// initialize elto
var new_elto = {
function_name: function_name,
begin_caller: creator_callstack_getTop().begin_callee, // llamante: FFFFFFFC, FFFFFFF0
end_caller: architecture.memory_layout[4].value, // llamante: FFFFFFF0, FFFFFF00
begin_callee: architecture.memory_layout[4].value, // llamado: FFFFFFF0, FFFFFF00
end_callee: architecture.memory_layout[4].value, // llamado: FFFFFFF0, FFFFFF00
registers_saved: arr_saved,
registers_modified: arr_modified,
registers_value: arr_value,
Expand Down Expand Up @@ -142,12 +157,16 @@ function creator_callstack_leave()
)
{
ret.ok = false;
// ret.msg = "The value of one or more protected registers is not kept between calls";
ret.msg = "The value of one or more registers was modified in the subrutine call";
ret.msg = "Possible failure in the parameter passing convention";
break;
}
}
}

if(creator_callstack_getTop().val.end_caller != architecture.memory_layout[4].value){
ret.ok = false;
ret.msg = "Possible failure in the parameter passing convention";
}
}

/*
Expand Down Expand Up @@ -199,6 +218,14 @@ function creator_callstack_leave()
*/

stack_call_registers.pop();

if (typeof window !== "undefined"){
app._data.begin_caller = creator_callstack_getTop().val.begin_caller; // llamante: FFFFFFFC, FFFFFFF0, FFFFFF00
app._data.end_caller = creator_callstack_getTop().val.end_caller; // llamante: FFFFFFF0, FFFFFF00, FFFFF000
app._data.begin_callee = creator_callstack_getTop().val.begin_callee; // llamado: FFFFFFF0, FFFFFF00, FFFFF000
app._data.end_callee = creator_callstack_getTop().val.end_callee; // llamado: FFFFFFF0, FFFFFF00, FFFFF000
}

return ret;
}

Expand Down Expand Up @@ -256,3 +283,38 @@ function creator_callstack_setTop( field, indexComponent, indexElement, value )
return ret;
}

function creator_callstack_setsp(value)
{

if (typeof window !== "undefined"){
app._data.end_callee = value; // llamado: FFFFFFF0, FFFFFF00, FFFFF000
}

// check params
if (0 == stack_call_registers.length) {
return;
}

// return the last element in the array
var elto = stack_call_registers[stack_call_registers.length - 1];
elto.end_callee = value;

}

function creator_callstack_reset()
{
var ret = {
ok: true,
msg: ""
};

// initialize stack_call
stack_call_registers = [];

if (typeof window !== "undefined"){
app._data.begin_caller = architecture.memory_layout[4].value;
app._data.end_caller = architecture.memory_layout[4].value;
app._data.begin_callee = architecture.memory_layout[4].value;
app._data.end_callee = architecture.memory_layout[4].value;
}
}
Loading