Re:Implement an emulator for a fantasy CPU in JavaScript
by showdead on Monday August 24, 2020 @10:04AM
(#24260746)
> x86 is notable in that you can cause a branch or jump without calling a branch or jump instruction.
I'm curious what you are referring to here. Are you talking about CMOV? Or INT/SYSCALL/SYSENTER? Or just the ability to trigger a fault handler? Or semantic games like push followed by ret?
Depending on the ISA [3][4][5], there can be jumps, branches, and subroutine transfers (or even a subset of those). Some can be based (conditional) on what value is in a primary register (often traditionally called the accumulator), a condition/flag/status register, a memory location, and even well known constants (0, 1, -1). Many ISAs have ways branching to a function/subroutine/procedure that can include adjusting a calling stack or transferring control to an OS kernel. x86 is notable in that you can cause a branch or jump without calling a branch or jump instruction.
[0] https://www.tutorialspoint.com/assembly_programming/assembly...
[1] https://thinkingeek.com/2013/01/19/arm-assembler-raspberry-p...
[2] https://www.ibm.com/developerworks/library/l-powasm3/index.h...
[3] https://en.wikipedia.org/wiki/Instruction_set_architecture
[4] https://en.wikipedia.org/wiki/Branch_(computer_science)
[5] https://en.wikipedia.org/wiki/Subroutine