## ALP Programming Guide and Reference

[prev][next][parent][TOC]

### Operation

    IF instruction = relative JMP  (* i.e. operand is rel8, rel16, or rel32 *)
    THEN
      EIP  EIP + rel18/16/32;
      IF OperandSize = 16
      THEN EIP  EIP AND 0000FFFFH;
      FI;
    FI;

    IF instruction = near indirect JMP
      (* i.e. operand is r/m16 or r/m32 *)
    THEN
      IF OperandSize = 16
      THEN
        EIP  [r/m16] AND 0000FFFFH;
      ELSE (* OperandSize = 32 *)
        EIP  [r/m32;
      FI;
    FI;

    IF (PE = 0 OR (PE = 1 AND VM = 1)) (* real mode or V86 mode *)
      AND instruction = far JMP
      (* i.e., operand type is m16:16, m16:32, ptr16:16, ptr16:32 *)
    THEN GOTO REAL-OR-V86-MODE;
      IF operand type = m16:16 or m16:32
      THEN (* indirect *)
       IF OperandSize = 16
       THEN
         CS:IP  [m16:16];
         EIP  EIP AND 0000FFFFH; (* clear upper 16 bits *)
       ELSE (* OperandSize = 32 *)
         CS:EIP  [m16:32];
       FI;
      FI;
      IF operand type = ptr16:16 or ptr16:32
      THEN
        IF OperandSize = 16
        THEN
          CS:IP  ptr16:16;
          EIP  EIP AND 0000FFFFH; (* clear upper 16 bits *)
        ELSE (* OperandSize = 32 *)
          CS:EIP  ptr16:32;
        FI;
      FI;
    FI;

    IF (PE = 1 AND VM = 0) (* Protected mode, not V86 mode *)
      AND instruction = far JMP
    THEN
      IF operand type = m16:16 or m16:32
      THEN (* indirect *)
        check access of EA dword;
        #GP(0) or #SS(0) IF limit violation;
      FI;
      Destination selector is not null ELSE #GP(0)
      Destination selector index is within its descriptor table limits ELSE #GP(selector)
      Depending on AR byte of destination descriptor;
        GOTO CONFORMING-CODE-SEGMENT;
        GOTO NONCONFORMING-CODE-SEGMENT;
        GOTO CALL-GATE;
        GOTO TASK-GATE;
        GOTO TASK-STATE-SEGMENT;
      ELSE #GP(selector); (* illegal AR byte in descriptor *)
    FI;

    CONFORMING-CODE-SEGMENT:
      Descriptor DPL must be ó CPL ELSE #GP(selector);
      Segment must be present ELSE #NP(selector);
      Instruction pointer must be within code-segment limit ELSE #GP(0);
      IF OperandSize = 32
      THEN Load CS:EIP from destination pointer;
      ELSE Load CS:IP from destination pointer;
      FI;
      Load CS register with new segment descriptor;

    NONCONFORMING-CODE-SEGMENT:
      RPL of destination selector must be ò CPL ELSE #GP(selector);
      Descriptor DPL must be = CPL ELSE #GP(selector);
      Segment must be present ELSE #NP(selector);
      Instruction pointer must be within code-segment limit ELSE #GP(0);
      IF OperandSize = 32
      THEN Load CS:EIP from destination pointer;
      ELSE Load CS:IP from destination pointer;
      FI;
      Load CS register with new segment descriptor;
      Set RPL field of CS register to CPL;

    CALL-GATE:
      Descriptor DPL must be ò CPL ELSE #GP(gate selector);
      Descriptor DPL must be ò gate selector RPL ELSE #GP(gate selector);
      Gate must be present ELSE #NP(gate selector);
      Examine selector to code segment given in call gate descriptor:
        Selector must not be null ELSE #GP(0);
        Selector must be within its descriptor table limits ELSE
          #GP(CS selector);
        Descriptor AR byte must indicate code segment
          ELSE #GP(CS selector);
        IF non-conforming
        THEN code-segment descriptor DPL must = CPL
        ELSE #GP(CS selector);
        FI;
        IF conforming
        THEN code-segment descriptor DPL must be ó CPL;
        ELSE #GP(CS selector);
        Code segment must be present ELSE #NP(CS selector);
        Instruction pointer must be within code-segment limit ELSE #GP(0);
        IF OperandSize = 32
        THEN Load CS:EIP from call gate;
        ELSE Load CS:IP from call gate;
        FI;
      Load CS register with new code-segment descriptor;
      Set RPL of CS to CPL

    TASK-GATE:
      Gate descriptor DPL must be ò CPL ELSE #GP(gate selector);
      Gate descriptor DPL must be ò gate selector RPL ELSE #GP(gate selector);
      Task Gate must be present ELSE #NP(gate selector);
      Examine selector to TSS, given in Task Gate descriptor:
        Must specify global in the local/global bit ELSE #GP(TSS selector);
        Index must be within GDT limits ELSE #GP(TSS selector);
        Descriptor AR byte must specify available TSS (bottom bits 00001);
          ELSE #GP(TSS selector);
        Task State Segment must be present ELSE #NP(TSS selector);
      SWITCH-TASKS (without nesting) to TSS;
      Instruction pointer must be within code-segment limit ELSE #GP(0);

    TASK-STATE-SEGMENT:
      TSS DPL must be ò CPL ELSE #GP(TSS selector);
      TSS DPL must be ò TSS selector RPL ELSE #GP(TSS selector);
      Descriptor AR byte must specify available TSS (bottom bits 00001)
        ELSE #GP(TSS selector);
      Task State Segment must be present ELSE #NP(TSS selector);
      SWITCH-TASKS (without nesting) to TSS;
      Instruction pointer must be within code-segment limit ELSE #GP(0);