Zardoz89 / dcpu_vm

Another DCPU-16 Virtual Machine
http://zardoz89.github.io/dcpu_vm/
MIT License
6 stars 2 forks source link

Segmentation error with lem_splash.bin on win32 #4

Closed lamogui closed 11 years ago

lamogui commented 11 years ago

Whatever the monitor i use. lem_splash always crash

lamogui commented 11 years ago

I open the lem_splash in debug mode: Step by step the splash is displayed. the last valid instruction is SET PC,POP then nest instructions are ???,A (0x0000) may be. If i return to run thes instructions dcpu_wm is not crashing but if i dont use the debug at all mode it crash

lamogui commented 11 years ago

Working diseapear with my commit

Zardoz89 commented 11 years ago

This can happen, if the DCPU core when are processing A or B parameter of an instrucction, don't enforce that = ram + XXXX is inside of ram size, so reads or writes outside of ram. To fix it, one could do:

ram + (uint16_t)(XXXX) 

Or:

ram + ( 0xFFFF & XXXX )

I think that I fixed it, but I could be missed to do it in a line of code.