Sunteți pe pagina 1din 18

ISA 1

MEMORY TO MEMORY ARCHITECTURE

ISA 1 - Memory to Memory

Ins tru ction format

General Instruction format

5-bit Opcode 47

3-bit Addressing Mode 43 42 40 39

19-bit operand

19-bit operand

Operand 2 36 21 19

Operand 1 1

Operand addressing modes and notations

000 100 101

Immediate Direct Indirect

# default &

ISA 1 - Memory to Memory

Ab br eviatio ns
Carry Flag Over-flow flag Sign Flag Zero Flag Parity Flag Instruction Pointer Addressing Modes CF OF SF ZF PF IP AMs

ISA 1 - Memory to Memory

Ins tru ction Set Su mmar y


Arithmetic instructions...........................................................................5
ADD SUB MUL DIV INC Addition .................................................................................................5 Subtraction .............................................................................................5 Signed multiplication .............................................................................6 Signed division.......................................................................................6 Increment the operand by 1 ....................................................................7

Logical instructions ................................................................................8


AND OR XOR SHL SHR ROL ROR NOT Bit-wise And ..........................................................................................8 Bit-wise OR............................................................................................8 Bit-wise XOR.........................................................................................9 Shift left by 1-bit ....................................................................................9 Shift operand right by 1-bit ..................................................................10 rotate operand left by 1-bit ...................................................................10 rotate operand right by 1-bit .................................................................11 Ones compliment negation..................................................................11

Control Transfer instructions ..............................................................12 Conditional Branches ...........................................................................12


JC JOF JS JP JZ Jump if carry (CF = 1)..........................................................................12 Jump if an over-flow (OF = 1) .............................................................13 Jump if Sign (SF = 1) ...........................................................................13 Jump if parity (PF = 1) .........................................................................14 Jump if result is zero (ZF =0) ...............................................................14

Unconditional branch ...........................................................................15


JUMP Jump .....................................................................................................15

Loop........................................................................................................15
LOOZ Loop until zero .....................................................................................15

Calls and Returns..................................................................................16


CALL Call procedure ......................................................................................16 RETURN Return from procedure .........................................................................16

Miscellaneous instructions ..................................................................17


NOP No operation.........................................................................................17

Data Movement instructions ................................................................18


LOAD Copy to a memory location ..................................................................18

ISA 1 - Memory to Memory

Instruction set reference


Arithmetic instructions

ADD
Opcode Format Description

Addition
10000 ADD AM operand 1, operand 2 Adds the operand 1 and operand2. Result modifies the operand 1. The ADD instruction performs integer addition. It evaluates the results for both signed and unsigned integer operands and sets the CF and OF flags to indicate a carry in the signed or unsigned result, respectively. The SF indicates the sign of the signed result. operand 1 operand 1 + operand 2 operand 2: immediate, direct and indirect operand 1: implied direct ZF, OF, SF and PF are set according to the result.

Operation AMs

Flags affected

SUB
Opcode Format Description

Subtraction
10001 SUB AM operand 1, operand 2 Subtracts operand 2 from operand 1. Result modifies operand 1. The SUB instruction performs integer subtraction. It evaluates the results for both signed and unsigned integer operands and sets the CF and OF to indicate a carry in the signed or unsigned result, respectively. The SF indicates the sign of the signed result. operand 1 operand 1 operand 2 operand 2: immediate, direct and indirect operand 1: implied direct

Operation AMs

Flags affected

ZF, OF, SF, CF and PF are set according to the result.


5

ISA 1 - Memory to Memory

MUL
Opcode Format Description

Signed multiplication
11011 MUL AM operand 1 (8-bit), operand 2 (8-bit) Performs signed multiplication on lower 8-bits of operand 1 and operand 2. Mul instruction produces a 16-bit result. operand1 (16-bit) operand 1 * Operand 2 (8 LSBs) (8 LSBs)

Operation

AMs

operand 2: immediate, direct and indirect operand 1: implied direct ZF, SF and PF are set according the product. OF and CF is cleared, as no overflow occurs in this situation and no carry considered.

Flags affected

DIV
Opcode Format Description

Signed division
11100 DIV AM operand 1, operand 2 Divides operand 1 by operand2. Div instruction produces an integer output. operand 1 operand 1 / operand 2 operand 2: immediate, direct and indirect operand 1: implied direct ZF, SF and PF are set according the product. OF and CF is cleared, as no overflow occurs in this situation and no carry considered.

Operation AMs

Flags affected

ISA 1 - Memory to Memory

INC
Opcode Format Description

Increment the operand by 1


01101 INC AM operand 1 Adds 1 to the operand. It evaluates for both signed and unsigned operands. op op +1 direct and indirect The OF, SF, ZF and PF are set according to the result.

Operation AMs Flags affected

ISA 1 - Memory to Memory

Logical instructions

AND
Opcode Format Description

Bit-wise And
10010 ADD AM operand 1, operand 2 Performs bit wise AND operation on the specified operands. Each bit of the result is set to 1 if both corresponding bits of the operands are 1; otherwise, it is set to 0. Result replaces the operand 1. operand 1 operand 1 AND operand 2 operand 2: immediate, direct and indirect operand 1: direct OF and CF are cleared; SF, ZF and PF are set according to the result.

Operation AMs

Flags affected

OR
Opcode Format Description

Bit-wise OR
10011 OR AM operand 1, operand 2 Performs bit wise OR operation on the specified operands. Each bit of the result is set to 0 if both corresponding bits of the operands are 0; otherwise, it is set to 1. Result replaces the operand 1. operand 1 operand 1 OR operand 2 operand 2: immediate, direct and indirect operand 1: direct OF and CF are cleared; SF, ZF and PF are set according to the result.

Operation AMs

Flags affected

ISA 1 - Memory to Memory

XOR
Opcode Format Description

Bit-wise XOR
10100 XOR AM operand 1, operand 2 Performs bit wise XOR operation on the specified operands. Each bit of the result is set to 0 if both corresponding bits of the operands are 1 or if both corresponding bits of the operands are 0; otherwise, it is set to 1. Result replaces the operand 1. operand 1 operand 1 XOR operand 2 operand 2: immediate, direct and indirect operand 1: direct OF and CF are cleared; SF, ZF and PF are set according to the result.

Operation AMs

Flags affected

SHL
Opcode Format Description

Shift left by 1-bit


10111 SHL AM operand 1 Shifts the bits in the operand to the left by one bit. Bit beyond the boundary is first shifted out. Least significant bit is cleared. CF MSB (original operand) direct and indirect The CF contains the value of the bit shifted out of the Acc. OF is set to zero if the value of the MSB of the result is same as the CF (that is, the top two bits of the original operand were same) ; otherwise it is set to 1. SF, ZF and PF are set according to the result.

Operation AMs Flags affected

ISA 1 - Memory to Memory

SHR
Opcode Format Description

Shift operand right by 1-bit


11000 SHR AM operand 1 Shifts the bits in the operand to the right by one bit. Bits beyond the boundary are shifted in to the CF. At the end of the shift operation CF contains the LSB of the original operand. Most significant bit is cleared. CF LSB (Acc) direct and indirect The CF contains the value of the bit shifted out of the operand frame. OF is set to the MSB of the original operand. SF, ZF and PF are set according to the result.

Operation AMs Flags affected

ROL
Opcode Format Description

rotate operand left by 1-bit


11001 ROL AM operand 1 shifts (rotates) the bits of the operand left by 1 bit. Instruction includes the CF in the rotation, first shifts the CF into the LSB, and shifts the MSB to the CF. CF receives a copy of the bit that was shifted from one end to the other end. OF is set to the exclusive OR of the CF (after the rotate) and the MSB of the result. tempCF MSB (operand) Operand operand (msb-1 down to 0) & CF CF tempCF OF MSB (operand) XOR CF (after the rotation) direct and indirect The CF contains the value of the bit shifted out. OF is set to the exclusive OR of the CF (after the rotate) and the MSB of the result. SF ZF and PF are not affected.

Operation

AMs Flags affected

10

ISA 1 - Memory to Memory

ROR
Opcode Format Description

rotate operand right by 1-bit


11010 ROR AM operand 1 shifts (rotates) the bits of the operand right by 1 bit. Instruction includes the CF in the rotation, first shifts the CF into the MSB and shifts the LSB to the CF. The original value of the CF is not a part of the result, but the CF receives a copy of the bit that was shifted from one end to the other end. OF is set to the exclusive OR of the two most significant bits of the operand. tempCF LSB(operand) MSB(operand) CF CF tempCF OF MSB(operand) XOR CF direct and indirect The CF contains the value of the bit shifted into it. OF is set to the exclusive-OR of the two most significant bits of the operand. SF ZF and PF are not affected.

Operation

AMs Flags affected

NOT
Opcode Format Description

Ones compliment negation


01101 NOT AM operand 1 Performs bit-wise NOT operation (each 1 is set to 0, and each 0 is set to 1) on the Acc and stores the result in it. operand NOT operand direct and indirect none

Operation AMs Flags affected

11

ISA 1 - Memory to Memory

Control Transfer instructions Conditional Branches

JC
Opcode Format Description

Jump if carry (CF = 1)


00001 JC {Signed offset (IP relative)} Check the state of the CF in the Flags register and, if the flag is set, performs a jump to the target instruction specified by the operand. If the condition is not satisfied, the jump is not performed and execution continues with the instruction following the JC instruction. The target instruction is specified with a relative offset (a signed offset relative to the current value of the IP register). A relative offset is specified as a label in the assembly code, but the machine code level it is encoded as a signed immediate value, which is added to the IP. IP IP + Operand IP relative addressing is applied in the address calculation none

Operation AM

Flags affected

12

ISA 1 - Memory to Memory

JOF
Opcode Format Description

Jump if an over-flow (OF = 1)


00010 JOF {Signed offset (IP relative)} Check the state of the OF in the Flags register and, if the flag is set, performs a jump to the target instruction specified by the operand. If the condition is not satisfied, the jump is not performed and execution continues with the instruction following the JOF instruction.

Operation AM

IP IP + Operand IP relative addressing is applied in the address calculation. none

Flags affected

JS
Opcode Format Description

Jump if Sign (SF = 1)


00011 JS {Signed offset (IP relative)} Check the state of the SF in the Flags register and, if the flag is set, performs a jump to the target instruction specified by the operand. If the condition is not satisfied, the jump is not performed and execution continues with the instruction following the JS instruction IP IP + Operand IP relative addressing is applied in the address calculation. none

Operation AM

Flags affected

13

ISA 1 - Memory to Memory

JP
Opcode Format Description

Jump if parity (PF = 1)


00100 JP {Signed offset (IP relative)} Check the state of the PF in the Flags register and, if the flag is set, performs a jump to the target instruction specified by the operand. If the condition is not satisfied, the jump is not performed and execution continues with the instruction following the JP instruction IP IP + Operand IP relative addressing is applied in the address calculation. none

Operation AM

Flags affected

JZ
Opcode Format Description

Jump if result is zero (ZF =0)


00101 JZ {Signed offset (IP relative)} Check the state of the ZF (Programmers Status Word register) and, if set, performs a jump to the target instruction specified by the operand. If the condition is not satisfied, the jump is not performed and execution continues with the instruction following the JZ instruction IP IP + Operand IP relative addressing is applied in the address calculation. none

Operation AM

Flags affected

14

ISA 1 - Memory to Memory

Unconditional branch

JUMP
Opcode Format

Jump
01111 JUMP {Signed offset (IP relative)}

Description

Transfers the program control to a different point of the instruction stream. The operand specified the signed offset being jumped to. This operand is an immediate signed offset.
IP IP + operand IP relative addressing is applied in the address calculation. none

Operation AM

Flags affected
Loop

LOOZ
Opcode Format Description

Loop until zero


01000 LOOZ {Signed offset (IP relative)} Performs a loop operation using an implied memory location as a counter. Each time the LOOZ instruction executes, the counter is decremented, then checked for 0. If the count =0, the loop terminates and the program execution continues with the instruction following the LOOZ instruction. If the count is not 0, a jump is performed to the specified operand, (a signed offset is specified in the instruction) which is presumably the instruction at the beginning of the loop. The decremented counter value is written back to the implied memory location whenever it is nor zero. Count Count 1 IF Count =0; Loop termination ELSE; IP IP + operand END IF IP relative addressing is applied in the address calculation. none

Operation

AM

Flags affected

15

ISA 1 - Memory to Memory

Calls and Returns

CALL
Opcode Format Description

Call procedure
01010 CALL {Immediate address} Saves IP in the implied memory location and branches to the procedure (called procedure) specified by the operand. This operand is an immediate value. When executing a CALL, the processor pushes the value of the IP register on to the implied return address (For use latter as a return-instruction pointer). The processor then branches to the address specified with instruction. implied return address IP IP Immediate address Immediate operand is used as the jumping location none

Operation

AM Flags affected

RETURN
Opcode Format Description

Return from procedure


01011 RET Transfers program control to a return address located in the implied return address. Return is made to the instruction that follows the CALL instruction. IP Contents of implied return address Contents of the implied return address is used as the jumping location none

Operation AM

Flags affected

16

ISA 1 - Memory to Memory

Miscellaneous instructions

NOP
Opcode Format Description

No operation
01110 NOP Performs no operation. Takes up space in the instruction stream but does not affect the context, except IP. none

Flags affected

17

ISA 1 - Memory to Memory

Data Movement instructions

LOAD
Opcode Format Description

Copy to a memory location


01100 LOAD AM operand 1, operand 2 Immediate Addressing Copy the 16-bit immediate source operand 2 to the destination memory address (operand 1). Direct Addressing Copy the contents of the source memory address (operand 2) to the destination memory address (operand1).

Operation

Immediate Addressing Memory (Operand 1) operand 2, 16-bit immediate value Direct Addressing Memory (Operand 1) Memory (Operand 2)

AM

Immediate and direct

Flags affected

none

18

S-ar putea să vă placă și