comse6998 / spring2024

Repository for COMSE6998 in the Spring 2024 term
2 stars 19 forks source link

Fixed drot; Add operations for jmpn and bb. #49

Closed tengjiang closed 8 months ago

tengjiang commented 8 months ago

My routine also uses jmpnz, but since @pxhuangxyl already defined it, I'm not going to do repetitive work.

jmpn is similar to jmpp.

The bb instruction can be broken down into cmp (also newly defined) and bb operations. cmp is just an operation to compare 2 registers, and also uses the CMPFLAGS.

Since it's hard to "go back some lines" in C++, I still use labels to "go back". To ensure that bb will only go back, and can only go back less than 16 words, I added the following lines to fixit().

assert(sourceaddr >= targetaddr);
_i = (sourceaddr/8) - (targetaddr/8); // Finally calculate and assert _i
assert(_i < 16);