Skip to content

Commit

Permalink
casos@F-@C
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoLuti committed Dec 16, 2016
1 parent 5f273d0 commit 340db46
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Casos-prueba/tests-cases-assembler-mat-FC
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
assembler

&&sentencias de declaracion de matrices
double matrix matDou [_i1][_i2]; &&@F esto es una anotacion de matriz arrobaF
double matrix matDou1 [_i1][_i2]; &&@C esto es una anotacion de matriz arrobaF

&&bloque ejecutable
{

matDou[_i0][_i2]:=_d2.;
matDou1[_i0][_i2]:=_d2.;
print("termino");
}
100 changes: 100 additions & 0 deletions Casos-prueba/tests-cases-assembler-mat-FC.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
.386
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.data
@cadena0 db "termino", 0
@cadena1 db "ax es igual a 2", 0
@cte0 dw 0
@cte1 dw 1
@cte2 dw 2
@cte3 dd 2.000000
@aux_0 dd ?
@aux_1 dd ?

mat@matDou dd 6 DUP(?)
mat@matDou1 dd 6 DUP(?)
maxInt dd 32768.0
minInt dd -32768.0
DivZero db "error de ejecucion: no se puede dividir por cero", 0
ConversionFailed db "error de ejecucion: no se puede realizar la conversion", 0
MatOutOfRange db "error de ejecucion: matriz fuera de rango", 0

.code
divZero:
invoke MessageBox, NULL, addr DivZero, addr DivZero, MB_OK
invoke ExitProcess, 0

conversionFailed:
invoke MessageBox, NULL, addr ConversionFailed, addr ConversionFailed, MB_OK
invoke ExitProcess, 0

matrixOutOfRange:
invoke MessageBox, NULL, addr MatOutOfRange, addr MatOutOfRange, MB_OK
invoke ExitProcess, 0

start:
;INICIO ASIGNACION DOUBLE
FLD @cte3
;INICIO CHEQUEO LIMITES ARRAY
MOV ax, @cte0
CMP ax, 2
JGE matrixOutOfRange
MOV ax, @cte2
CMP ax, 3
JGE matrixOutOfRange
;FIN CHEQUEO LIMITES ARRAY
;INICIO CALCULO POS ARRAY
;FILAS!!!!!!!!!!!!!!!!
MOV ax, @cte0
IMUL ax, 3
ADD ax, @cte2
;-------------------------------
CMP ax, 2
JNE label_1
invoke MessageBox, NULL, addr @cadena1, addr @cadena1, MB_OK
label_1:
;-------------------------------
IMUL ax, 4
;FIN CALCULO POS ARRAY
MOV ebx, OFFSET mat@matDou
MOV ecx, 0
MOV cx, ax
MOV eax, ecx
ADD ebx, eax
FSTP DWORD PTR [ebx]
;FINAL ASIGNACION DOUBLE
;INICIO ASIGNACION DOUBLE
FLD @cte3
;INICIO CHEQUEO LIMITES ARRAY
MOV ax, @cte0
CMP ax, 2
JGE matrixOutOfRange
MOV ax, @cte2
CMP ax, 3
JGE matrixOutOfRange
;FIN CHEQUEO LIMITES ARRAY
;INICIO CALCULO POS ARRAY
;COLUMNAS!!!!!!!!!!!!!!!!
MOV ax, @cte2
IMUL ax, 2
ADD ax, @cte0
IMUL ax, 4
;FIN CALCULO POS ARRAY
MOV ebx, OFFSET mat@matDou1
MOV ecx, 0
MOV cx, ax
MOV eax, ecx
ADD ebx, eax
FSTP DWORD PTR [ebx]
;FINAL ASIGNACION DOUBLE
;INICIO PRINT
invoke MessageBox, NULL, addr @cadena0, addr @cadena0, MB_OK
;FINAL PRINT
invoke ExitProcess, 0
end start
2 changes: 2 additions & 0 deletions codegenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ void CodeGenerator::generateInstructions(Node * node) {
/*calculo posicion*/
instructions.push_back(";INICIO CALCULO POS ARRAY");
if(symbolsTable->getEntry(node->dato.toStdString())->storage == "rows"){
instructions.push_back(";FILAS!!!!!!!!!!!!!!!!");
instruccion = "MOV ax, " + hijoIzq;
instructions.push_back(instruccion);
instruccion = "IMUL ax, " + QString::number(symbolsTable->getEntry(node->dato.toStdString())->limit2);
Expand All @@ -351,6 +352,7 @@ void CodeGenerator::generateInstructions(Node * node) {
instructions.push_back(instruccion);
}
else if(symbolsTable->getEntry(node->dato.toStdString())->storage == "columns"){
instructions.push_back(";COLUMNAS!!!!!!!!!!!!!!!!");
instruccion = "MOV ax, " + hijoDer;
instructions.push_back(instruccion);
instruccion = "IMUL ax, " + QString::number(symbolsTable->getEntry(node->dato.toStdString())->limit1);
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int main(int argc, char *argv[])
printSymbolsTable();
parser->printSintacticTree();

parser->generateAssembler("assembler.asm");
parser->generateAssembler("tests-cases-assembler-mat-FC.asm");

return 0;
}
Expand Down

0 comments on commit 340db46

Please sign in to comment.