{
File : NEWLSH.mc
Author : Gwan Santosa
Date : 5-Nov-85 9:47:30
(LSH A B)
Performs left shift A by B position,
where A and B are smallpl
Procedure :
After preliminary checking for valid arguments, rotate A by 8 position (swap h and l byte),
For B between 0 and 7, check h byte to see if it is ok to shift.
For B between 8 and 15, as long as h byte is 00, it is ok to shift 8 position first, then
do the remainder by going to subroutine that process shifting between 0 and 7 positions.
}
@LSHOP: Ybus ← TOSH xor smallpl, ZeroBr, c1, opcode[347'b]; {Check if B is smallpl}
Rx ← 10, BRANCH[LSHER1, $], c2;
Q ← 0FF, c3; {Q contains mask for B>=8}
MAR ← [rhS, S - 1], c1;
Ybus ← TOS - Rx, CarryBr, CANCELBR[$, 2], c2; {Check if B>15}
TT ← MD, BRANCH[$, LSHER3] c3; {Fetch A Hi}
MAR ← [rhS, S + 0], c1;
Ybus ← TT xor smallpl, ZeroBr, c2; {Check if A is smallpl}
Rx ← MD, BRANCH[LSHER2, $], c3; {Fetch A Lo}
TT ← Rx LRot8, c1; {Rotate A by 8}
uTOS ← TOS, YDisp, c2; {Select how many shifting}
TOS ← TOS and 07, DISP4[SHSEL], c3;
L0SH: TOS ← Rx, GOTO[LSHF4], c1, at[0, 10, SHSEL];
L1SH: Q ← 80, c1, at[1, 10, SHSEL];
TT ← TT and Q, ZeroBr, c2;
TT ← Rx LShift1, SE ← 0, BRANCH[LSER0, $], c3;
TOS ← TT, GOTO[LSHF3], c1;
L2SH: Q ← 0C0, c1, at[2, 10, SHSEL];
TT ← TT and Q, ZeroBr, c2;
TT ← Rx LShift1, SE ← 0, BRANCH[LSER1, $], c3;
TOS ← TT LShift1, SE ← 0, GOTO[LSHF3], c1;
L3SH: Q ← 0E0, c1, at[3, 10, SHSEL];
TT ← TT and Q, ZeroBr, c2;
TT ← Rx LRot4, BRANCH[LSER2, $], c3;
TOS ← TT RShift1, SE ← 0, GOTO[LSHF3], c1;
L4SH: Q ← 0F0, c1, at[4, 10, SHSEL];
TT ← TT and Q, ZeroBr, c2;
TT ← Rx LRot4, BRANCH[LSER3, $], c3;
TOS ← TT, GOTO[LSHF3], c1;
L5SH: Q ← 0F8, c1, at[5, 10, SHSEL];
TT ← TT and Q, ZeroBr, c2;
TT ← Rx LRot4, BRANCH[LSER4, $], c3;
TOS ← TT LShift1, SE ← 0, GOTO[LSHF3], c1;
L6SH: Q ← 0FC, c1, at[6, 10, SHSEL];
TT ← TT and Q, ZeroBr, c2;
TT ← Rx LRot4, BRANCH[LSER5, $], c3;
TT ← TT LShift1, SE ← 0, c1;
TT ← TT LShift1, SE ← 0, GOTO[LSHF5], c2;
L7SH: Q ← 0FE, c1, at[7, 10, SHSEL];
Ybus ← TT and Q, ZeroBr, c2;
BRANCH[LSER6, $], c3;
TOS ← TT RShift1,SE ← 0, GOTO[LSHF3], c1;
L8SH: Ybus ← TT and Q, ZeroBr, GOTO[CNR8], c1, at[8, 10, SHSEL];
L9SH: Ybus ← TT and Q, ZeroBr, GOTO[CNR8], c1, at[9, 10, SHSEL];
LASH: Ybus ← TT and Q, ZeroBr, GOTO[CNR8], c1, at[0A, 10, SHSEL];
LBSH: Ybus ← TT and Q, ZeroBr, GOTO[CNR8], c1, at[0B, 10, SHSEL];
LCSH: Ybus ← TT and Q, ZeroBr, GOTO[CNR8], c1, at[0C, 10, SHSEL];
LDSH: Ybus ← TT and Q, ZeroBr, GOTO[CNR8], c1, at[0D, 10, SHSEL];
LESH: Ybus ← TT and Q, ZeroBr, GOTO[CNR8], c1, at[0E, 10, SHSEL];
Ybus ← Rx xor 1, ZeroBr, c1, at[0F, 10, SHSEL];
BRANCH[LSER7, $], c2; {Can only shift 15 position if A=1}
TOS ← Rx RRot1, c3;
S ← S - 2, GOTO[IB.pc1], c1;
CNR8: BRANCH[LSER8, $], c2;
Q ← Rx, c3; {Exchange Rx and TT}
Rx ← TT, c1;
Ybus ← TOS, YDisp, c2; {Process the remainding shifting}
TT ← Q, DISP4[SHSEL], c3;
LSHER1: GOTO[ufnX1], c3;
LSHER3: GOTO[ufnX2], c1;
LSHER2: GOTO[ufnX2], c1;
LSER7: uTOSH ← TOSH, GOTO[ufnZ1], c3;
LSER0: uTOSH ← TOSH, GOTO[ufnZ2], c1;
LSER1: uTOSH ← TOSH, GOTO[ufnZ2], c1;
LSER2: uTOSH ← TOSH, GOTO[ufnZ2], c1;
LSER3: uTOSH ← TOSH, GOTO[ufnZ2], c1;
LSER6: uTOSH ← TOSH, GOTO[ufnZ2], c1;
LSER8: uTOSH ← TOSH, GOTO[ufnZ1], c3;
LSER4: uTOSH ← TOSH, GOTO[ufnZ2], c1;
LSER5: uTOSH ← TOSH, GOTO[ufnZ2], c1;
LSHF5: TOS ← TT, GOTO[B2FN], c3;
LSHF4: S ← S - 2, c2;
GOTO[B1FN], c3;
B2FN: S ← S - 2, GOTO[IB.pc1], c1;
LSHF3: S ← S - 2, c2;
Noop, c3;
B1FN: GOTO[IB.pc1], c1;