Skip to content

Commit e3d4401

Browse files
committed
Fix bug in alignment restriction
1 parent a35b8bc commit e3d4401

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Memory/InstructionMemory.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ func (instruction *LoadInstruction) parse() error {
880880
instruction.offset = uint(offset)
881881

882882
//check for alignment restriction
883-
if (instruction.reg2+instruction.offset)%4 != 0 {
883+
if (getRegisterValue(instruction.reg2)+int64(instruction.offset))%4 != 0 {
884884
return errors.New("Alignment restriction violation in : " + instruction.inst)
885885
}
886886

@@ -939,7 +939,7 @@ func (instruction *StoreInstruction) parse() error {
939939
instruction.offset = uint(offset)
940940

941941
//check for alignment restriction
942-
if (instruction.reg2+instruction.offset)%4 != 0 {
942+
if (getRegisterValue(instruction.reg2)+int64(instruction.offset))%4 != 0 {
943943
return errors.New("Alignment restriction violation in : " + instruction.inst)
944944
}
945945

@@ -994,7 +994,7 @@ func (instruction *LoadHalfInstruction) parse() error {
994994
instruction.offset = uint(offset)
995995

996996
//check for alignment restriction
997-
if (instruction.reg2+instruction.offset)%4 != 0 && (instruction.reg2+instruction.offset)%4 != 2 {
997+
if (getRegisterValue(instruction.reg2)+int64(instruction.offset))%4 != 0 && (getRegisterValue(instruction.reg2)+int64(instruction.offset))%4 != 2 {
998998
return errors.New("Alignment restriction violation in : " + instruction.inst)
999999
}
10001000

@@ -1058,7 +1058,7 @@ func (instruction *StoreHalfInstruction) parse() error {
10581058
instruction.offset = uint(offset)
10591059

10601060
//check for alignment restriction
1061-
if (instruction.reg2+instruction.offset)%4 != 0 && (instruction.reg2+instruction.offset)%4 != 2 {
1061+
if (getRegisterValue(instruction.reg2)+int64(instruction.offset))%4 != 0 && (getRegisterValue(instruction.reg2)+int64(instruction.offset))%4 != 2 {
10621062
return errors.New("Alignment restriction violation in : " + instruction.inst)
10631063
}
10641064

0 commit comments

Comments
 (0)