I am making an emulator for Z80 binaries but I cannot find out whether all the integer data types are signed or unsigned from the manual or from google. So are the n开发者_Go百科umbers from registers A
,B
...HL
,BC
etc signed or not?
Also, in machine code are the bytes/words/addresses which come after the instructions as arguments signed or unsigned?
Like in these examples (from 8080/Z80 Instruction Set):
8080 Mnemonic Z80 Mnemonic Machine Code Operation
------------- ------------ ------------ ---------
MVI A,byte LD A,byte 3Ebyte A <- byte
LXI B,word LD BC,word 01word BC <- word
JMP address JP address C3address PC <- address
Thanks in advance.
The registers can contain either, and most operands calculate both answers at the same time because of Two's complement. Some instructions do however need information whether the containing value is signed or unsigned. They exist in two forms, one for signed and one for unsigned. Can't remember whether Z80 has any of these.
See (1.) Absolute addresses are unsigned and relative addresses (branches) are signed, to be able to jump backwards.
On many machines, the only differences between signed and unsigned numbers are the way in which magnitude comparisons are performed, and the way in which shorter values are converted to longer ones (note that many processors' multiply operations effectively convert shorter types to longer ones, and division inherently performs magnitude comparisons). When performing any type of operation other than those above, signed and unsigned operands are treated precisely (bit-for-bit) the same way, so there's no need to distinguish them.
AKAIK, Assembly language data and transfer instructions don't contain sign information. Both data and transfer operations define only data size. Sign information is part of some instructions, like signed/unsigned multiplication instructions. So, the same register may be handled by imul instruction as signed integer, and by mul instruction as unsigned integer.
精彩评论