Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is cool stuff. A few noob questions:

I notice that the 0x00-ff memory space has no 0xff byte and that 0xfe seems to change a lot, but it's not explained. What's going on here? What's in 0xfe and why is 0xff not shown?

I noticed that there's no multiplication operator. Does that mean that multiplication was performed using looping addition? What about division, floating-point, et al?



* Not sure I follow this question. The zero page (address 0x00-FF) can store any values 0x00-FF.

* This is an old processor, so it doesn't support fancy stuff like multiplication and division and floating-point. Generally you just try to avoid multiplication whenever possible, or keep it to powers of 2, since that can be done with shift operations. You can do multiplication using looped addition, but if you were to implement it you'd want to use a constant-time binary multiplication algorithm instead.


If you open the Monitor in the first example and step through it in the debugger, the byte at address 0xFE changes at every step. This doesn't seem to be documented and it's not clear to me why it's doing that.

Moreover the content of 0xFE keeps changing even after execution stops (if you keep hitting the "step" button).

0xFF isn't even listed, but a load from that address seems to work (with value 0x00). [ETA: actually, that seems to be a quirk of the Monitor's initial config. If you set "length" to 100 instead of ff, you can see byte 0xFF in the monitor. Nothing wrong or weird there.]


Examining it a bit more, The value in 0xFE can be ignored. It is just a random value. I don't know why.

There is a function called 'setRandomByte' that is called on every debugger step, but it has no comments so it may just be leftover debugging logic.


Ahh, I see what you mean.

0xFF doesn't show up because the Monitor's length is set to 0xFF, which is 255. If you set the length to 0x100 it properly shows the first 256 entries.

As for the value at 0xFE, I don't know.


Hey, thanks. Yeah, I haven't yet fully explained all of the simulator.

0xfe is a random number - a new random byte is generated on every instruction.

0xff contains the ASCII code of the last key pressed.

My simulator is adapted from the one at http://6502asm.com/beta/index.html - that has a help screen with some more info. I mostly cleaned up the (atrocious) JavaScript and added a memory monitor and disassembler (and implemented a few instructions they'd left out).


LSR (logical shift right) is an unsigned division by 2. ASL (arithmetic shift left) is an unsigned multiplication by 2.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: