Skip to content

Commit

Permalink
CALLPA/CALLPB
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuerfel21 committed Mar 26, 2024
1 parent 07f84de commit 90d6afd
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions page/branch.md
Expand Up @@ -138,8 +138,14 @@ Note: if **D**estination is zero, REP does nothing.

<%=p2instrinfo('call-a')%>
<%=p2instrinfo('call-d',joinup:true)%>

<%=p2instrinfo('callpa')%>
<%=p2instrinfo('callpb')%>
<%=p2instrinfo('callpb',joinup:true)%>
CALLPA and CALLPB call the address given by **S**ource and copies the value of **D**estination into PA or PB.

See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.



<%=p2instrinfo('ret')%>
RET pops an address off the internal stack (**TODO Link**) and jumps to that address.
Expand Down Expand Up @@ -179,7 +185,7 @@ See [RETA](#reta), but substitute **PTRA** with **PTRB**.
<%=p2instrinfo('calld-a')%>
<%=p2instrinfo('calld-s',joinup:true)%>

## Conditional branch addressing
## Short branch addressing

For conditional branches (TJ\*/DJ\*/IJ\*) the address (**S**ource) can be absolute or relative.
To specify an absolute address, **S**ource must be a register containing a 20-bit address value.
Expand All @@ -194,78 +200,78 @@ And yes, it _is_ mildly confusing that the branch _destination_ is encoded by th
<%=p2instrinfo('tjz')%>
TJZ jumps to the address described by **S**ource if the value in **D**estination is zero.

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.

<%=p2instrinfo('tjnz')%>
TJNZ jumps to the address described by **S**ource if the value in **D**estination is _not_ zero.

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.

<%=p2instrinfo('tjf')%>
TJF jumps to the address described by **S**ource if the value in **D**estination is full of ones (i.e. equals -1 / `$FFFFFFFF`).

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.

<%=p2instrinfo('tjnf')%>
TJNF jumps to the address described by **S**ource if the value in **D**estination is _not_ full of ones (i.e. does _not_ equal -1 / `$FFFFFFFF`).

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.

<%=p2instrinfo('tjs')%>
TJS jumps to the address described by **S**ource if the value in **D**estination is negative (i.e. bit 31 is 1).

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.

<%=p2instrinfo('tjns')%>
TJNS jumps to the address described by **S**ource if the value in **D**estination is positive (i.e. bit 31 is 0).

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.

<%=p2instrinfo('tjv')%>
TJV tests the value in **D**estination against the C flag and jumps to the address described by **S**ource if **D**estination has overflowed (**D**estination[31] != C). This instruction requires that C has been set to the "correct sign" by the ADDS / ADDSX / SUBS / SUBSX / CMPS / CMPSX / SUMx instruction that is to be checked for overflow.

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.

## Modify and Branch

<%=p2instrinfo('djz')%>
DJZ decrements the value in **D**estination, writes the result, and jumps to the address described by **S**ource if the
result is zero.

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.

<%=p2instrinfo('djnz')%>
DJNZ decrements the value in **D**estination, writes the result, and jumps to the address described by **S**ource if the
result is _not_ zero.

This instruction is very commonly used for counted loops. In certain cases, it can be substituted with [REP](#rep).

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.

<%=p2instrinfo('djf')%>
DJF decrements the value in **D**estination, writes the result, and jumps to the address described by **S**ource if the
result is -1 / `$FFFFFFFF` (i.e underflow/borrow occurred).

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.

<%=p2instrinfo('djnf')%>
DJNF decrements the value in **D**estination, writes the result, and jumps to the address described by **S**ource if the
result is _not_ -1 / `$FFFFFFFF` (i.e no underflow/borrow occurred).

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.

<%=p2instrinfo('ijz')%>
DJZ increments the value in **D**estination, writes the result, and jumps to the address described by **S**ource if the
result is zero.

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.


<%=p2instrinfo('ijnz')%>
IJNZ increments the value in **D**estination, writes the result, and jumps to the address described by **S**ource if the
result is _not_ zero.

See [Conditional branch addressing](#conditional-branch-addressing) for details on how **S**ource encodes the branch target.
See [Short branch addressing](#short-branch-addressing) for details on how **S**ource encodes the branch target.

## Branch on Event

Expand Down

0 comments on commit 90d6afd

Please sign in to comment.