Skip to content

Commit

Permalink
Updated to version 1.4 (Events log)
Browse files Browse the repository at this point in the history
Initial implementation of the Events log. Now the events that are
produced are logged into the events log panel.

Minor fixes.
  • Loading branch information
parraman committed Dec 12, 2017
1 parent 98d09c1 commit 65e2d0e
Show file tree
Hide file tree
Showing 25 changed files with 6,962 additions and 241 deletions.
1 change: 1 addition & 0 deletions .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"prefix": "app",
"styles": [
"../node_modules/codemirror/lib/codemirror.css",
"bootstrap.css",
"styles.css"
],
"scripts": [],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "asm-simulator",
"version": "1.3.0",
"version": "1.4.0",
"license": "MIT",
"scripts": {
"ng": "ng",
Expand Down
122 changes: 61 additions & 61 deletions src/app/alu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class ALUOperation implements SystemEvent {
default:
break;
}

return ret;

}
Expand Down Expand Up @@ -440,12 +440,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check16bitsOperation(summand1 + summand2);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishAddition(ALUOperationType.ADD,
summand1, summand2, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -454,12 +454,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check8bitsOperation(summand1 + summand2);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishAddition(ALUOperationType.ADDB,
summand1, summand2, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -468,12 +468,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check16bitsOperation(minuend - subtrahend);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishSubstraction(ALUOperationType.SUB,
minuend, subtrahend, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -482,12 +482,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check8bitsOperation(minuend - subtrahend);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishSubstraction(ALUOperationType.SUBB,
minuend, subtrahend, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -496,12 +496,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check16bitsOperation(multiplicand * multiplier);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishMultiplication(ALUOperationType.MUL,
multiplicand, multiplier, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -510,12 +510,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check8bitsOperation(multiplicand * multiplier);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishMultiplication(ALUOperationType.MULB,
multiplicand, multiplier, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -529,12 +529,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check16bitsOperation(Math.floor(dividend / divisor));

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishDivision(ALUOperationType.DIV,
dividend, divisor, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -548,12 +548,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check8bitsOperation(Math.floor(dividend / divisor));

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishDivision(ALUOperationType.DIVB,
dividend, divisor, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -562,12 +562,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check16bitsOperation(operand1 & operand2);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishBitwiseOp(ALUOperationType.AND,
operand1, operand2, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -576,12 +576,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check8bitsOperation(operand1 & operand2);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishBitwiseOp(ALUOperationType.ORB,
operand1, operand2, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -590,12 +590,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check16bitsOperation(operand1 | operand2);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishBitwiseOp(ALUOperationType.OR,
operand1, operand2, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -604,12 +604,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check8bitsOperation(operand1 | operand2);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishBitwiseOp(ALUOperationType.ORB,
operand1, operand2, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -618,12 +618,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check16bitsOperation(operand1 ^ operand2);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishBitwiseOp(ALUOperationType.XOR,
operand1, operand2, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -632,12 +632,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check8bitsOperation(operand1 ^ operand2);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishBitwiseOp(ALUOperationType.XORB,
operand1, operand2, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -646,12 +646,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check16bitsOperation(~operand);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishBitwiseNegation(ALUOperationType.NOT,
operand, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -660,12 +660,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check8bitsOperation(~operand);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishBitwiseNegation(ALUOperationType.NOTB,
operand, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -674,12 +674,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check16bitsOperation(operand << places);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishBitshiftOp(ALUOperationType.SHL,
operand, places, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -688,12 +688,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check8bitsOperation(operand << places);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishBitshiftOp(ALUOperationType.SHLB,
operand, places, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -702,12 +702,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check16bitsOperation(operand >>> places);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishBitshiftOp(ALUOperationType.SHR,
operand, places, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand All @@ -716,12 +716,12 @@ export class ArithmeticLogicUnit {

const ret = ArithmeticLogicUnit.check8bitsOperation(operand >>> places);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

this.publishBitshiftOp(ALUOperationType.SHRB,
operand, places, ret.result, ret.carryFlag, ret.zeroFlag);

this.SR.carry = ret.carryFlag;
this.SR.zero = ret.zeroFlag;

return ret.result;

}
Expand Down
8 changes: 4 additions & 4 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<div class="nav navbar-nav">
<div class="btn-group">
<button type="button" class="btn btn-success navbar-btn" (click)="run()" *ngIf="!isRunning"><span class="glyphicon glyphicon-play"></span> Run</button>
<button type="button" class="btn btn-default navbar-btn" (click)="stop()" *ngIf="isRunning"><span class="glyphicon glyphicon-stop"></span> Stop</button>
<button type="button" class="btn btn-default navbar-btn" (click)="executeStep()" [disabled]="isRunning"><span class="glyphicon glyphicon-forward"></span> Step</button>
</div>
<button type="button" class="btn btn-default navbar-btn" (click)="reset()">Reset</button>
</div>
<div class="navbar-header navbar-right"><a class="navbar-brand navbar-link" href="#">16-bit Assembler Simulator</a></div>
<div class="nav navbar-nav navbar-right"><a class="navbar-brand navbar-link" href="#">16-bit Assembler Simulator</a></div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="col-xs-6">
<div class="panel panel-default">
<div class="panel-body">
<h4>Code <small>(<a (click)="setCodeSample(1)">Sample 1</a>, <a (click)="setCodeSample(2)">Sample 2</a>, <a (click)="setCodeSample(3)">Sample 3</a>, <a (click)="setCodeSample(4)">Sample 4</a>, <a (click)="setCodeSample(5)">Sample 5</a>)</small></h4>
Expand All @@ -29,7 +29,7 @@ <h4>Code <small>(<a (click)="setCodeSample(1)">Sample 1</a>, <a (click)="setCode
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-xs-6">
<div class="panel panel-default">
<div class="panel-body">
<div style="width:60%;display:inline-block;float:left;text-align:center;">
Expand Down

0 comments on commit 65e2d0e

Please sign in to comment.