What is the meaning of M in the Z80 statement ADD A,M

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












8














Recently I have been trying to compile CP/M 2.2 from source. When I try to assemble, everything works except for the instructions ADD A,M and SBC A,M, which the assembler returns a syntax error. I have not done much Z80, so I am a little confused on what the source code means by M?



I am using the CP/M 2.2 Source (Z80 Mnemonics) from the Unofficial CP/M Website.










share|improve this question



















  • 2




    It might be helpful if you link the source in question and explain where you acquired it.
    – Raffzahn
    Dec 14 at 1:55






  • 1




    without seeing the code we can only guess if it means (HL) memory access or direct 8/16 bit constant N or NN... but my bet is the (HL). It also could be some Macro
    – Spektre
    Dec 14 at 8:02







  • 1




    LD A,M is actually 8080 syntax, not Z80.
    – tofro
    Dec 14 at 12:26















8














Recently I have been trying to compile CP/M 2.2 from source. When I try to assemble, everything works except for the instructions ADD A,M and SBC A,M, which the assembler returns a syntax error. I have not done much Z80, so I am a little confused on what the source code means by M?



I am using the CP/M 2.2 Source (Z80 Mnemonics) from the Unofficial CP/M Website.










share|improve this question



















  • 2




    It might be helpful if you link the source in question and explain where you acquired it.
    – Raffzahn
    Dec 14 at 1:55






  • 1




    without seeing the code we can only guess if it means (HL) memory access or direct 8/16 bit constant N or NN... but my bet is the (HL). It also could be some Macro
    – Spektre
    Dec 14 at 8:02







  • 1




    LD A,M is actually 8080 syntax, not Z80.
    – tofro
    Dec 14 at 12:26













8












8








8







Recently I have been trying to compile CP/M 2.2 from source. When I try to assemble, everything works except for the instructions ADD A,M and SBC A,M, which the assembler returns a syntax error. I have not done much Z80, so I am a little confused on what the source code means by M?



I am using the CP/M 2.2 Source (Z80 Mnemonics) from the Unofficial CP/M Website.










share|improve this question















Recently I have been trying to compile CP/M 2.2 from source. When I try to assemble, everything works except for the instructions ADD A,M and SBC A,M, which the assembler returns a syntax error. I have not done much Z80, so I am a little confused on what the source code means by M?



I am using the CP/M 2.2 Source (Z80 Mnemonics) from the Unofficial CP/M Website.







z80 assembly cp-m






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 14 at 3:57









Alex Hajnal

3,48531633




3,48531633










asked Dec 14 at 1:43









tergav17

412




412







  • 2




    It might be helpful if you link the source in question and explain where you acquired it.
    – Raffzahn
    Dec 14 at 1:55






  • 1




    without seeing the code we can only guess if it means (HL) memory access or direct 8/16 bit constant N or NN... but my bet is the (HL). It also could be some Macro
    – Spektre
    Dec 14 at 8:02







  • 1




    LD A,M is actually 8080 syntax, not Z80.
    – tofro
    Dec 14 at 12:26












  • 2




    It might be helpful if you link the source in question and explain where you acquired it.
    – Raffzahn
    Dec 14 at 1:55






  • 1




    without seeing the code we can only guess if it means (HL) memory access or direct 8/16 bit constant N or NN... but my bet is the (HL). It also could be some Macro
    – Spektre
    Dec 14 at 8:02







  • 1




    LD A,M is actually 8080 syntax, not Z80.
    – tofro
    Dec 14 at 12:26







2




2




It might be helpful if you link the source in question and explain where you acquired it.
– Raffzahn
Dec 14 at 1:55




It might be helpful if you link the source in question and explain where you acquired it.
– Raffzahn
Dec 14 at 1:55




1




1




without seeing the code we can only guess if it means (HL) memory access or direct 8/16 bit constant N or NN... but my bet is the (HL). It also could be some Macro
– Spektre
Dec 14 at 8:02





without seeing the code we can only guess if it means (HL) memory access or direct 8/16 bit constant N or NN... but my bet is the (HL). It also could be some Macro
– Spektre
Dec 14 at 8:02





1




1




LD A,M is actually 8080 syntax, not Z80.
– tofro
Dec 14 at 12:26




LD A,M is actually 8080 syntax, not Z80.
– tofro
Dec 14 at 12:26










2 Answers
2






active

oldest

votes


















16














In 8080 Assembler M is the memory referenced to by HL.



Depending on the assembler used this would be written as




  • ADD M (Original Intel 8080 syntax) or


  • ADD A,M (Later Intel syntax as used for example by CP/M's own ASM (*1))

The Z80 assembler equivalent would be




  • ADD A,(HL) (Zilog notation)


Are you sure the source you're compiling made for the Z80 (and a Z80 assembler) at all?



CP/M is by default written in 8080 Assembly, not Z80 or any other substitute. It would make sense that the source you got is meant to be compiled with ASM, as this was the default assembler for CP/M. It would be unusual if it's formatted for any later (Z80) assembler.



Wiki got some condensed remarks about the changes Zilog made to the 8080 Assembly Syntax, like the usage of full register as you might have expected in this example. DR's ASM was an inbetween product, adhering (mostly) to Intel syntax while supporting the Z80 as well.




*1 - Later assemblers where often able to compile 8080 as well as Z80 but using 8080 notation.






share|improve this answer






















  • In case this is actually Z80 syntax as OP claimed, an alternative interpretation would be that there's a constant M defined in the source code somehwere and you need to add the constant to the accumulator. So, opcode 0xCE.
    – Wilson
    Dec 19 at 10:26



















3














Depending on the compiler you use, you may need to explicitly state using preprocessor directives that you use 8080 commands. M80 uses .z80 and .8080 to instruct using respective instruction set mnemonics. See https://www.classic-computers.org.nz/system-80/software-manuals/manuals-Macro-80-Assembler.pdf page 20 (16 on the document's page).



If it will not compile in 8080 mode (due to Z80 directives in the source), then it means that sources are altered.The easiest way is to replace M with (HL), but I would not be surprised if resulting executable will not work properly at all.






share|improve this answer




















  • Why might the executable not run? Z80 will run any 8080 code unchanged.
    – Toby Speight
    Dec 14 at 11:16






  • 1




    Because if it is currently having 8080 mnemonic which does not exist in Z80 set, but at the same time having Z80 mnemonics which do not exist in 8080 set assumes that someone incorrectly touched the code, and its integrity may be compromised (= may not work properly). We do not talk about binary code which of course can be run by Z80, but about source code which does not compile properly returning error.
    – Anonymous
    Dec 14 at 13:20











  • @Anonymous Either all is 8080 assembly and assembled as such, or all is Z80 assembly and the assembler knows that or it simply won't produce an executable at all. But it should never produce a non-working executable.
    – tofro
    Dec 14 at 18:49










  • @tofro people may produce incorrect sequences of mnemonics which then converted to incorrect sequences of instructions. In other words - program does not perform what it was expected to perform. I do consider mixing 8080 and Z80 mnemonics as incorrect.
    – Anonymous
    Dec 14 at 19:33










  • The assembler should do the same - and reject the program.
    – tofro
    Dec 14 at 19:46










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "648"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f8546%2fwhat-is-the-meaning-of-m-in-the-z80-statement-add-a-m%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









16














In 8080 Assembler M is the memory referenced to by HL.



Depending on the assembler used this would be written as




  • ADD M (Original Intel 8080 syntax) or


  • ADD A,M (Later Intel syntax as used for example by CP/M's own ASM (*1))

The Z80 assembler equivalent would be




  • ADD A,(HL) (Zilog notation)


Are you sure the source you're compiling made for the Z80 (and a Z80 assembler) at all?



CP/M is by default written in 8080 Assembly, not Z80 or any other substitute. It would make sense that the source you got is meant to be compiled with ASM, as this was the default assembler for CP/M. It would be unusual if it's formatted for any later (Z80) assembler.



Wiki got some condensed remarks about the changes Zilog made to the 8080 Assembly Syntax, like the usage of full register as you might have expected in this example. DR's ASM was an inbetween product, adhering (mostly) to Intel syntax while supporting the Z80 as well.




*1 - Later assemblers where often able to compile 8080 as well as Z80 but using 8080 notation.






share|improve this answer






















  • In case this is actually Z80 syntax as OP claimed, an alternative interpretation would be that there's a constant M defined in the source code somehwere and you need to add the constant to the accumulator. So, opcode 0xCE.
    – Wilson
    Dec 19 at 10:26
















16














In 8080 Assembler M is the memory referenced to by HL.



Depending on the assembler used this would be written as




  • ADD M (Original Intel 8080 syntax) or


  • ADD A,M (Later Intel syntax as used for example by CP/M's own ASM (*1))

The Z80 assembler equivalent would be




  • ADD A,(HL) (Zilog notation)


Are you sure the source you're compiling made for the Z80 (and a Z80 assembler) at all?



CP/M is by default written in 8080 Assembly, not Z80 or any other substitute. It would make sense that the source you got is meant to be compiled with ASM, as this was the default assembler for CP/M. It would be unusual if it's formatted for any later (Z80) assembler.



Wiki got some condensed remarks about the changes Zilog made to the 8080 Assembly Syntax, like the usage of full register as you might have expected in this example. DR's ASM was an inbetween product, adhering (mostly) to Intel syntax while supporting the Z80 as well.




*1 - Later assemblers where often able to compile 8080 as well as Z80 but using 8080 notation.






share|improve this answer






















  • In case this is actually Z80 syntax as OP claimed, an alternative interpretation would be that there's a constant M defined in the source code somehwere and you need to add the constant to the accumulator. So, opcode 0xCE.
    – Wilson
    Dec 19 at 10:26














16












16








16






In 8080 Assembler M is the memory referenced to by HL.



Depending on the assembler used this would be written as




  • ADD M (Original Intel 8080 syntax) or


  • ADD A,M (Later Intel syntax as used for example by CP/M's own ASM (*1))

The Z80 assembler equivalent would be




  • ADD A,(HL) (Zilog notation)


Are you sure the source you're compiling made for the Z80 (and a Z80 assembler) at all?



CP/M is by default written in 8080 Assembly, not Z80 or any other substitute. It would make sense that the source you got is meant to be compiled with ASM, as this was the default assembler for CP/M. It would be unusual if it's formatted for any later (Z80) assembler.



Wiki got some condensed remarks about the changes Zilog made to the 8080 Assembly Syntax, like the usage of full register as you might have expected in this example. DR's ASM was an inbetween product, adhering (mostly) to Intel syntax while supporting the Z80 as well.




*1 - Later assemblers where often able to compile 8080 as well as Z80 but using 8080 notation.






share|improve this answer














In 8080 Assembler M is the memory referenced to by HL.



Depending on the assembler used this would be written as




  • ADD M (Original Intel 8080 syntax) or


  • ADD A,M (Later Intel syntax as used for example by CP/M's own ASM (*1))

The Z80 assembler equivalent would be




  • ADD A,(HL) (Zilog notation)


Are you sure the source you're compiling made for the Z80 (and a Z80 assembler) at all?



CP/M is by default written in 8080 Assembly, not Z80 or any other substitute. It would make sense that the source you got is meant to be compiled with ASM, as this was the default assembler for CP/M. It would be unusual if it's formatted for any later (Z80) assembler.



Wiki got some condensed remarks about the changes Zilog made to the 8080 Assembly Syntax, like the usage of full register as you might have expected in this example. DR's ASM was an inbetween product, adhering (mostly) to Intel syntax while supporting the Z80 as well.




*1 - Later assemblers where often able to compile 8080 as well as Z80 but using 8080 notation.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 14 at 11:26

























answered Dec 14 at 1:50









Raffzahn

44.9k5103181




44.9k5103181











  • In case this is actually Z80 syntax as OP claimed, an alternative interpretation would be that there's a constant M defined in the source code somehwere and you need to add the constant to the accumulator. So, opcode 0xCE.
    – Wilson
    Dec 19 at 10:26

















  • In case this is actually Z80 syntax as OP claimed, an alternative interpretation would be that there's a constant M defined in the source code somehwere and you need to add the constant to the accumulator. So, opcode 0xCE.
    – Wilson
    Dec 19 at 10:26
















In case this is actually Z80 syntax as OP claimed, an alternative interpretation would be that there's a constant M defined in the source code somehwere and you need to add the constant to the accumulator. So, opcode 0xCE.
– Wilson
Dec 19 at 10:26





In case this is actually Z80 syntax as OP claimed, an alternative interpretation would be that there's a constant M defined in the source code somehwere and you need to add the constant to the accumulator. So, opcode 0xCE.
– Wilson
Dec 19 at 10:26












3














Depending on the compiler you use, you may need to explicitly state using preprocessor directives that you use 8080 commands. M80 uses .z80 and .8080 to instruct using respective instruction set mnemonics. See https://www.classic-computers.org.nz/system-80/software-manuals/manuals-Macro-80-Assembler.pdf page 20 (16 on the document's page).



If it will not compile in 8080 mode (due to Z80 directives in the source), then it means that sources are altered.The easiest way is to replace M with (HL), but I would not be surprised if resulting executable will not work properly at all.






share|improve this answer




















  • Why might the executable not run? Z80 will run any 8080 code unchanged.
    – Toby Speight
    Dec 14 at 11:16






  • 1




    Because if it is currently having 8080 mnemonic which does not exist in Z80 set, but at the same time having Z80 mnemonics which do not exist in 8080 set assumes that someone incorrectly touched the code, and its integrity may be compromised (= may not work properly). We do not talk about binary code which of course can be run by Z80, but about source code which does not compile properly returning error.
    – Anonymous
    Dec 14 at 13:20











  • @Anonymous Either all is 8080 assembly and assembled as such, or all is Z80 assembly and the assembler knows that or it simply won't produce an executable at all. But it should never produce a non-working executable.
    – tofro
    Dec 14 at 18:49










  • @tofro people may produce incorrect sequences of mnemonics which then converted to incorrect sequences of instructions. In other words - program does not perform what it was expected to perform. I do consider mixing 8080 and Z80 mnemonics as incorrect.
    – Anonymous
    Dec 14 at 19:33










  • The assembler should do the same - and reject the program.
    – tofro
    Dec 14 at 19:46















3














Depending on the compiler you use, you may need to explicitly state using preprocessor directives that you use 8080 commands. M80 uses .z80 and .8080 to instruct using respective instruction set mnemonics. See https://www.classic-computers.org.nz/system-80/software-manuals/manuals-Macro-80-Assembler.pdf page 20 (16 on the document's page).



If it will not compile in 8080 mode (due to Z80 directives in the source), then it means that sources are altered.The easiest way is to replace M with (HL), but I would not be surprised if resulting executable will not work properly at all.






share|improve this answer




















  • Why might the executable not run? Z80 will run any 8080 code unchanged.
    – Toby Speight
    Dec 14 at 11:16






  • 1




    Because if it is currently having 8080 mnemonic which does not exist in Z80 set, but at the same time having Z80 mnemonics which do not exist in 8080 set assumes that someone incorrectly touched the code, and its integrity may be compromised (= may not work properly). We do not talk about binary code which of course can be run by Z80, but about source code which does not compile properly returning error.
    – Anonymous
    Dec 14 at 13:20











  • @Anonymous Either all is 8080 assembly and assembled as such, or all is Z80 assembly and the assembler knows that or it simply won't produce an executable at all. But it should never produce a non-working executable.
    – tofro
    Dec 14 at 18:49










  • @tofro people may produce incorrect sequences of mnemonics which then converted to incorrect sequences of instructions. In other words - program does not perform what it was expected to perform. I do consider mixing 8080 and Z80 mnemonics as incorrect.
    – Anonymous
    Dec 14 at 19:33










  • The assembler should do the same - and reject the program.
    – tofro
    Dec 14 at 19:46













3












3








3






Depending on the compiler you use, you may need to explicitly state using preprocessor directives that you use 8080 commands. M80 uses .z80 and .8080 to instruct using respective instruction set mnemonics. See https://www.classic-computers.org.nz/system-80/software-manuals/manuals-Macro-80-Assembler.pdf page 20 (16 on the document's page).



If it will not compile in 8080 mode (due to Z80 directives in the source), then it means that sources are altered.The easiest way is to replace M with (HL), but I would not be surprised if resulting executable will not work properly at all.






share|improve this answer












Depending on the compiler you use, you may need to explicitly state using preprocessor directives that you use 8080 commands. M80 uses .z80 and .8080 to instruct using respective instruction set mnemonics. See https://www.classic-computers.org.nz/system-80/software-manuals/manuals-Macro-80-Assembler.pdf page 20 (16 on the document's page).



If it will not compile in 8080 mode (due to Z80 directives in the source), then it means that sources are altered.The easiest way is to replace M with (HL), but I would not be surprised if resulting executable will not work properly at all.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 14 at 6:45









Anonymous

92316




92316











  • Why might the executable not run? Z80 will run any 8080 code unchanged.
    – Toby Speight
    Dec 14 at 11:16






  • 1




    Because if it is currently having 8080 mnemonic which does not exist in Z80 set, but at the same time having Z80 mnemonics which do not exist in 8080 set assumes that someone incorrectly touched the code, and its integrity may be compromised (= may not work properly). We do not talk about binary code which of course can be run by Z80, but about source code which does not compile properly returning error.
    – Anonymous
    Dec 14 at 13:20











  • @Anonymous Either all is 8080 assembly and assembled as such, or all is Z80 assembly and the assembler knows that or it simply won't produce an executable at all. But it should never produce a non-working executable.
    – tofro
    Dec 14 at 18:49










  • @tofro people may produce incorrect sequences of mnemonics which then converted to incorrect sequences of instructions. In other words - program does not perform what it was expected to perform. I do consider mixing 8080 and Z80 mnemonics as incorrect.
    – Anonymous
    Dec 14 at 19:33










  • The assembler should do the same - and reject the program.
    – tofro
    Dec 14 at 19:46
















  • Why might the executable not run? Z80 will run any 8080 code unchanged.
    – Toby Speight
    Dec 14 at 11:16






  • 1




    Because if it is currently having 8080 mnemonic which does not exist in Z80 set, but at the same time having Z80 mnemonics which do not exist in 8080 set assumes that someone incorrectly touched the code, and its integrity may be compromised (= may not work properly). We do not talk about binary code which of course can be run by Z80, but about source code which does not compile properly returning error.
    – Anonymous
    Dec 14 at 13:20











  • @Anonymous Either all is 8080 assembly and assembled as such, or all is Z80 assembly and the assembler knows that or it simply won't produce an executable at all. But it should never produce a non-working executable.
    – tofro
    Dec 14 at 18:49










  • @tofro people may produce incorrect sequences of mnemonics which then converted to incorrect sequences of instructions. In other words - program does not perform what it was expected to perform. I do consider mixing 8080 and Z80 mnemonics as incorrect.
    – Anonymous
    Dec 14 at 19:33










  • The assembler should do the same - and reject the program.
    – tofro
    Dec 14 at 19:46















Why might the executable not run? Z80 will run any 8080 code unchanged.
– Toby Speight
Dec 14 at 11:16




Why might the executable not run? Z80 will run any 8080 code unchanged.
– Toby Speight
Dec 14 at 11:16




1




1




Because if it is currently having 8080 mnemonic which does not exist in Z80 set, but at the same time having Z80 mnemonics which do not exist in 8080 set assumes that someone incorrectly touched the code, and its integrity may be compromised (= may not work properly). We do not talk about binary code which of course can be run by Z80, but about source code which does not compile properly returning error.
– Anonymous
Dec 14 at 13:20





Because if it is currently having 8080 mnemonic which does not exist in Z80 set, but at the same time having Z80 mnemonics which do not exist in 8080 set assumes that someone incorrectly touched the code, and its integrity may be compromised (= may not work properly). We do not talk about binary code which of course can be run by Z80, but about source code which does not compile properly returning error.
– Anonymous
Dec 14 at 13:20













@Anonymous Either all is 8080 assembly and assembled as such, or all is Z80 assembly and the assembler knows that or it simply won't produce an executable at all. But it should never produce a non-working executable.
– tofro
Dec 14 at 18:49




@Anonymous Either all is 8080 assembly and assembled as such, or all is Z80 assembly and the assembler knows that or it simply won't produce an executable at all. But it should never produce a non-working executable.
– tofro
Dec 14 at 18:49












@tofro people may produce incorrect sequences of mnemonics which then converted to incorrect sequences of instructions. In other words - program does not perform what it was expected to perform. I do consider mixing 8080 and Z80 mnemonics as incorrect.
– Anonymous
Dec 14 at 19:33




@tofro people may produce incorrect sequences of mnemonics which then converted to incorrect sequences of instructions. In other words - program does not perform what it was expected to perform. I do consider mixing 8080 and Z80 mnemonics as incorrect.
– Anonymous
Dec 14 at 19:33












The assembler should do the same - and reject the program.
– tofro
Dec 14 at 19:46




The assembler should do the same - and reject the program.
– tofro
Dec 14 at 19:46

















draft saved

draft discarded
















































Thanks for contributing an answer to Retrocomputing Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f8546%2fwhat-is-the-meaning-of-m-in-the-z80-statement-add-a-m%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay