This may have been documented before but with assembling MOV M,M with assemblers ASM or MAC, debuggers DDT or SID produces the 76h HLT opcode with no error reported. I just discovered this today for myself. Has anyone else heard of this ? ApparentlyMOV M,M is not valid even though moving other registers upon themselves is valid ?
Larry G
However, the TDL assembler flags it.
TDL Z80 CP/M DISK ASSEMBLER VERSION 2.21 PAGE 1
MOVM -
0100 .LOC 0100H
.IDENT MOVM
; there is no MOV M,M
; register R evaluates as follows:
; B=0 C=1 D=2 E=3 H=4 L=5 M=6 A=7
0100 77 MOV M,A
0101 70 MOV M,B
0102 71 MOV M,C
0103 72 MOV M,D
0104 73 MOV M,E
0105 74 MOV M,H
0106 75 MOV M,L
A 0107 76 MOV M,M?
.END
Apparently MOV M,M is not valid even though moving other registers upon themselves is valid ?
On Saturday, October 21, 2023 at 8:23:36 AM UTC-5, retrogear wrote:MOV M,M is not valid even though moving other registers upon themselves is valid ?
This may have been documented before but with assembling MOV M,M with assemblers ASM or MAC, debuggers DDT or SID produces the 76h HLT opcode with no error reported. I just discovered this today for myself. Has anyone else heard of this ? Apparently
Larry G
This is not surprising, it is just something everyone knew back then (that HLT was the same as the MOV M,M instruction).
On 22/10/2023 1:05 am, Douglas Miller wrote:...
This is not surprising, it is just something everyone knew back then (that HLT was the same as the MOV M,M instruction).Only to those who tried it. That MOV M,M results in HLT is either very significant
- or about as meaningful as an image seen in a toasted cheese sandwich.
On Saturday, October 21, 2023 at 8:16:50 PM UTC-5, dxf wrote:instruction coding made it clear. Intel simply used MOV M,M to mean HLT since it was a useless instruction otherwise. It may have even had some undesirable side-effects if left to the logic to actually try and do a MOV M,M, thereby protecting the CPU
On 22/10/2023 1:05 am, Douglas Miller wrote:...
Only to those who tried it. That MOV M,M results in HLT is either very significant
This is not surprising, it is just something everyone knew back then (that HLT was the same as the MOV M,M instruction).
- or about as meaningful as an image seen in a toasted cheese sandwich.
It was quite obvious to those that studied the instruction set, which most people had to do in order to program effectively in assembly. A quick look at the instruction table shows HLT in the position where MOV M,M would be. Just looking at the binary
HLT needed to be assigned an opcode and 76h was available. The encoding for M is 6
- as is PSW or SP. None of these are regular registers. There's no reason to expect
MOV M,M to work any better than MOV M,PSW or MOV M,SP.
On Saturday, 21 October 2023 at 20:33:56 UTC+1, Douglas Miller wrote:
On Saturday, October 21, 2023 at 10:38:40 AM UTC-5, retrogear wrote:
However, the TDL assembler flags it.
TDL Z80 CP/M DISK ASSEMBLER VERSION 2.21 PAGE 1
MOVM -
I have now confirmed MOV 7,0 works with M80 as I suspected and also note that M80 also supported opcodes as operands, so MVI A,CMA is equivalent to MVI A,2FH.0100 .LOC 0100H
.IDENT MOVM
; there is no MOV M,M
; register R evaluates as follows:
; B=0 C=1 D=2 E=3 H=4 L=5 M=6 A=7
0100 77 MOV M,A
0101 70 MOV M,B
0102 71 MOV M,C
0103 72 MOV M,D
0104 73 MOV M,E
0105 74 MOV M,H
0106 75 MOV M,L
A 0107 76 MOV M,M?
.ENDM80 also complains about MOV M,M, but produces valid output files anyway.
DRI tools do less checking. But both (M80 and DRI tools) have some much more egregious lapses, such as turning "MVI A,B" into "MVI A,0" and "MOV A,0" into "MOV A,B". Those occur without any messages at all.It was not uncommon for assemblers of the period to treat registers as numbers, with B = 0. This would explain why the instructions you noted do not issue a warning. Although I haven't checked, I would
not be surprised if MOV 7,0 was also treated as MOV A,B.
Apparently MOV M,M is not valid even though moving other registers upon themselves is valid ?
This would need a 2 address machine, which it isn't.
It was not uncommon for assemblers of the period to treat registers as numbers, with B = 0. This would explain why the instructions you noted do not issue a warning. Although I haven't checked, I would
not be surprised if MOV 7,0 was also treated as MOV A,B.
On Saturday, October 21, 2023 at 10:38:40 AM UTC-5, retrogear wrote:
However, the TDL assembler flags it.
TDL Z80 CP/M DISK ASSEMBLER VERSION 2.21 PAGE 1
MOVM -
It was not uncommon for assemblers of the period to treat registers as numbers, with B = 0. This would explain why the instructions you noted do not issue a warning. Although I haven't checked, I would0100 .LOC 0100H
.IDENT MOVM
; there is no MOV M,M
; register R evaluates as follows:
; B=0 C=1 D=2 E=3 H=4 L=5 M=6 A=7
0100 77 MOV M,A
0101 70 MOV M,B
0102 71 MOV M,C
0103 72 MOV M,D
0104 73 MOV M,E
0105 74 MOV M,H
0106 75 MOV M,L
A 0107 76 MOV M,M?
.ENDM80 also complains about MOV M,M, but produces valid output files anyway.
DRI tools do less checking. But both (M80 and DRI tools) have some much more egregious lapses, such as turning "MVI A,B" into "MVI A,0" and "MOV A,0" into "MOV A,B". Those occur without any messages at all.
Apparently MOV M,M is not valid even though moving other registers upon themselves is valid ?Interesting, so a good place to halt rather than try something impossible.
This would need a 2 address machine, which it isn't.
...to add this logic for HLT, but also had reason to do something similar to protect programmers from MOV M,M, they may have opted to combine the two and save on decoding logic.
Most of the 8080 instructions fall into opcode patterns which would translate into relatively simple decoding logic on the chip. But some instructions, such as HLT, that have no such pattern would require "more expensive" decoding logic. So if they had
Intel assembler (Intel ISIS or Microsoft M80.COM in 8080 mode, but NOT ASM.COM) had one moreNote for M80 the parentheses around the instructions are not needed. The O error is because of the second comma on the line.
"trick up the sleeve":
Single byte operations can be immediate arguments. This even highlights an error in M80.COM:
0000' CSEG
.8080
O 0000' 06 78 MVI B,(MOV A,B)
0002' 78 MOV A,B
0003' 06 21 MVI B,(LXI H)
0005' 3E 00 MVI A,0
A 0007' 76 MOV M,M
END
Note the O error is fatal! But the code is correct. And MOV M,M does produce 76h, which is correct.
Very "code is data". Zilog assembler didn't have this.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 546 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 43:53:48 |
| Calls: | 10,392 |
| Files: | 14,066 |
| Messages: | 6,417,241 |