Introduction
The assembly-like language is a low-level programming language designed to interact with the computer’s hardware. It uses mnemonics for machine-level operations. Each mnemonic is associated with a specific machine instruction, allowing programmers to control various hardware components directly. Below is the list of available instructions and their respective functions.
Instruction Set
1. Data Movement Instructions
These instructions are used to move data between registers, memory locations, or the stack:
- nop (0x00): No operation.
- lda [address](0x01): Load data into register A.
- ldb [address](0x02): Load data into register B.
- sta [address](0x03): Store data from register A into memory.
- stb [address](0x04): Store data from register B into memory.
- movab (0x32): Move data from register A to B.
- movba (0x33): Move data from register B to A.
- mspa (0x44): Move stack pointer to register A.
- mspb (0x45): Move stack pointer to register B.
- ldaa (0x3c): Load data from address in register A to A.
- ldab (0x3d): Load data from address in register A to B.
- ldba (0x3e): Load data from address in register B to A.
- ldbb (0x3f): Load data from address in register B to B.
- stab (0x40): Store data from register A into address in B.
- stba (0x41): Store data from register B into address in A.
2. Arithmetic Instructions
These instructions perform arithmetic operations:
- addab (0x05): Add data in registers A and B.
- addaa (0x06): Add data in register A to itself.
- addbb (0x07): Add data in register B to itself.
- subab (0x09): Subtract data in register B from register A.
- subba (0x0a): Subtract data in register A from register B.
- mulab (0x0b): Multiply data in registers A and B.
- mulaa (0x0c): Multiply data in register A to itself.
- mulbb (0x0d): Multiply data in register B to itself.
- divab (0x0f): Divide data in register A by data in register B.
- divba (0x10): Divide data in register B by data in register A.
3. Logical Instructions
These instructions perform bitwise operations:
- nota (0x11): Perform bitwise NOT on register A.
- notb (0x12): Perform bitwise NOT on register B.
- andab (0x13): Perform bitwise AND between registers A and B.
- andba (0x14): Perform bitwise AND between registers B and A.
- orab (0x15): Perform bitwise OR between registers A and B.
- orba (0x16): Perform bitwise OR between registers B and A.
- xorab (0x17): Perform bitwise XOR between registers A and B.
- xoraa (0x18): Perform bitwise XOR on register A.
- xorbb (0x19): Perform bitwise XOR on register B.
- xorba (0x1a): Perform bitwise XOR between registers B and A.
4. Shift Instructions
These instructions shift the bits of the data in the registers:
- shra (0x1b): Shift register A’s bits to the right.
- shrb (0x1c): Shift register B’s bits to the right.
- shla (0x1d): Shift register A’s bits to the left.
- shlb (0x1e): Shift register B’s bits to the left.
5. Comparison Instructions
These instructions compare the data in registers A and B:
- cmpab (0x1f): Compare data in registers A and B.
- cmpba (0x20): Compare data in registers B and A.
6. Stack and Control Flow Instructions
These instructions control the flow of the program or manage the stack:
- pusha (0x21): Push register A onto the stack.
- pushb (0x22): Push register B onto the stack.
- popa (0x23): Pop data from the stack into register A.
- popb (0x24): Pop data from the stack into register B.
- pop (0x46): Pop data from the stack.
- call [address](0x25): Call a subroutine (jump to address).
- ret (0x26): Return from subroutine.
- jmp [address](0x27): Jump to a specific address.
- jz [address](0x28): Jump if zero flag is set.
- jac [address](0x29): Jump if carry flag of operation is set.
- jsc [address](0x2a): Jump if carry flag of bit-wise shift is set.
- je [address](0x2b): Jump if equal flag is set.
- jn [address](0x2c): Jump if not equal flag is set.
- jg [address](0x2d): Jump if greater flag is set.
- jl [address](0x2e): Jump if less flag is set.
7. I/O and Miscellaneous Instructions
These instructions are used for input/output and other operations:
- outa (0x2f): Output data from register A.
- outb (0x30): Output data from register B.
- hlt (0x31): Halt the program.
- ina (0x38): Increment register A by 1.
- inb (0x39): Increment register B by 1.
- dea (0x3a): Decrement register A by 1.
- deb (0x3b): Decrement register B by 1.
- ldva (0x42): Load next word into register A.
- ldvb (0x43): Load next word into register B.
- testa (0x47): Test the value of register A.
- testb (0x48): Test the value of register B.