Original Post
I'm learning assembly and there are a few things I'm worried about. I want to translate machine language 6502 machine language to x86 and I'm not sure if I can get away with it for reasons I will explain. LDA (Load Accumulator) is a 6502 instruction that can be translated to "mov al, $data" and I would like to directly translate a lot of other instructions in this manner. Such as the LDX, LDA, etc.. Instructions I'm worried about are stack functions or flag functions. Do I have to use a ROMs memory space to store the stack or can I get away with using the x86's? x86's meaning MY processor or the host. A good reason why I'm so worried is when the simulator/emulator for the 6502's routines are finished and general the application program stuff like Windows message loop and what not. If I use the host processor for a stack and processor state (i.e. pushes and pops), will I end back up were I should if where I left off? Meaning, what if some code pushes or pops something off the stack that I put there? That is one reason why I'm worried about using the host processor because I don't want other code messing up the emulation. Second, I'm worried if I should write the stack to the ROM's memory space or not. I wouldn't have to if I was using the host. This *could* speed. But certain tings I know I will have to write to the ROM's memory. Things like read/write routines that are specific, like memory addressing. But not if I use the host for most of the other stuff, right? For example: See what I mean. I only see a problem when I go back to PLA (Pull accumulator) and I get a wrong value because something else pushed something there! But so far, I only see that I would have to write to ROM memory space when I cross an instruction that does so. Other wise, I belive I can get away with completely using the host. Only problems I see arethe stack and maybe the X,Y registers. I think BX, BP, SI or one of those sorts, may work. Please help with some advice. Thanks in advance :D
LDA #$10
STA $2020 // would have to make a write here!
LDA #$20
PHA // wouldn't have to write, use host's stack (i.e. "push al" for x86)