Hypothetical Machine Language


Basic Architecture of our Hypothetical Computer


Legends
Instruction

Each Instruction requires 2 bytes : one for storing the operand and one for the operand.
InstructionExplanationExample
Memory Instructions
    MOV ADDR
Move contents of ADDR to ACCMov 102
    STO ADDR
Store contents of ACC to ADDRSTO 102
    SET VALUE
Stores Value in ACC
Arithmatic Inst
    ADD ADDR
Add contents of ADDR to ACC and Store result in ACCADD 102
    SUB ADDR
Subtract contents of ADDR to ACC and Store result in ACCSUB 102
    MUL ADDR
Multiply contents of ADDR to ACC and Store result in ACCMUL 102
    DIV ADDR
Divide contents of ADDR to ACC and Store result in ACCDIV 102
Logical Inst
    AND ADDR
AND contents of ADDR to ACC and Store result in ACCAND 103
    OR ADDR
OR contents of ADDR to ACC and Store result in ACCOR 103
Comparison Inst
    CMP ADDR
Compare Contents of ADDR with ACC and Store 1 in ACC equal otherwise 0CMP 102
    GTE ADDR
Compare Contents of ADDR with ACC and Store 1 in ACC if the former is greater or equal otherwise 0GTE 102
    LE ADDR
Compare Contents of ADDR with ACC and Store 1 in ACC if the former is less otherwise 0LE 102
Branching Inst
    BTO ADDR
The next instruction to be executed is ADDRBTO 36
    BIT ADDR
If ACC is 1, the next instruction to be executed is ADDR otherwise it is the next instruction in the sequence.BIT 38
I/O Inst
    GET ADDR
Read from Input device and store in ADDRGET 105
    PRI ADDR
Display value in ADDR in Output DeviceSET 105
Examples of Machine Language Programs
A program to add two numbers

000 Get 101
002 GET 102
004 MOV 101
006 ADD 102
008 MOV 103
010 PRI 103

A program to evaluate an expression a*a+b-c

000 GET 101
002 GET 102
004 GET 103
006 MOV 101
008 MUL 101
010 ADD 102
012 SUB 103
014 STO 104
016 PRI 106

A program to evaluate roots of a quardratic equation

000 GET 101
002 GET 102
004 GET 103