I want simulate 8051 using the x86 instruction. In 32 bits mode, I have to rotate left to get the carry flag. it is more steps to get the overflow flag. Do you know how to AL, BL, CL, DL, to do arithmetic operation and update the flags.
Asked
Active
Viewed 177 times
0
-
2x86 `add al, cl` updates the x86 EFLAGS with carry, overflow, etc. ("set according to the result": https://www.felixcloutier.com/x86/add / https://en.wikipedia.org/wiki/FLAGS_register). IDK why you want to calculate it manually if you're writing an 8051 simulator in x86 asm. Just use `sahf` (and `seto` if you need it) to read the FLAGS after an 8-bit x86 instruction using the 8051 "guest"'s data. – Peter Cordes Jan 25 '22 at 03:15
1 Answers
-1
Thank you very much. "ADD AL, CL" work. I am not quite familiar with x86 ISA, because of 8bit 16bit 32bit 64bit and its compatibility. I try ADD instruction to see the flags changing all day long and could not get the satisfy answer until I see your post. X86 machine could not execute 8051 code. 8051 simulator is perform by my program including fetch-decode-execute. If I could use 8-bit x86 ISA, then the execution part of 8051 simulator could use native machine code. In fact, I am planing to simulate 8051 ALU by using verilog if x86 ISA could not support 8 bit operation.

qjpdzjcb
- 1
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 26 '22 at 09:45