Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguity #17

Closed
ghost opened this issue Jun 10, 2015 · 1 comment
Closed

Ambiguity #17

ghost opened this issue Jun 10, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 10, 2015

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 :-)

@Schweigi
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant