Schweigi / assembler-simulator

Simple 8-bit Assembler Simulator with Angular.js

Home Page:http://schweigi.github.io/assembler-simulator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ambiguity

opened this issue · comments

I really like what you have done here. Very fun to play with. Some possible issues I see with the addressing of memory, opt codes and registers. I say possible because there is also a chance I just don't understand assembly and how the CPU and memory addressing works. But here I go anyway:

You have opt codes 1-97, however, memory addresses start at 0 and the registers start at 0 as well.

For example, the following set of instructions loaded into memory can be confusing to read:

JMP start
hello: DB "abc" ; Variable
DB 0 ; String terminator

start:
MOV A, hello
MOV B, 232

JMP is set to memory location 0 as 1F. Memory location 1 is set to 6 (the memory location and not the MOV opt code). In memory, address 6 stores a MOV opt code which is the number 6. Memory location 7 is set to 00 which addresses the register A and not the memory location 0 which is currently set to the JMP opt code. Empty memory cells are set to 00 and do not refer to the memory location 0 or the A register.

Would it be best to start the registers at 0, start the memory at 9 and opt codes at 265? I hope I was clear and forgive me if I am not understanding any of this :-)

commented

Since the CPU and Memory are 8bit its not possible to start the opcodes at the values above 255.

It would be possible to make the values more compact, e.g. currently the instruction ADD C needs 2 bytes (1x OpCode, 1x Operand) and it would probably be possible to compact it to one byte. But I wanted to keep it as simple as possible.