“operands do not match” assembler syntax error









up vote
2
down vote

favorite












I wrote this code, in assembly, to calculate (4*7)+5, but I get these errors:




(18) wrong parameters: MOV ax,m1

(18) operands do not match: 16 bit register and 8 bit address.




 .MODEL SMALL
.stack 100h
.data
m1 DB 4
m2 DB 7
m3 DB 5
m4 DB ?
.code
main PROC
mov ax,@data
mov ds,ax
mov ax,m1
mul ax,m2
add ax,m3
mov m4,ax

BEGIN ENDP
END main









share|improve this question



















  • 2




    @movcmpret: no it won't. This is x86 with MASM-like syntax. The error is that symbol names magically get a size associated with them when declared that way, and mov ax, m1 is doing a word load from a byte "variable", and the assembler stops you from making that mistake. One solution is to use dw and make everything a word, or to use byte registers (al)
    – Peter Cordes
    Nov 11 at 17:26











  • I am a beginner in the assembly language, can you help me?
    – Faisal
    Nov 11 at 17:26










  • I just edited my last comment.
    – Peter Cordes
    Nov 11 at 17:27










  • I will trying now
    – Faisal
    Nov 11 at 17:34










  • I do it. But If i running the program I didn't now where i can see the result.
    – Faisal
    Nov 11 at 17:51















up vote
2
down vote

favorite












I wrote this code, in assembly, to calculate (4*7)+5, but I get these errors:




(18) wrong parameters: MOV ax,m1

(18) operands do not match: 16 bit register and 8 bit address.




 .MODEL SMALL
.stack 100h
.data
m1 DB 4
m2 DB 7
m3 DB 5
m4 DB ?
.code
main PROC
mov ax,@data
mov ds,ax
mov ax,m1
mul ax,m2
add ax,m3
mov m4,ax

BEGIN ENDP
END main









share|improve this question



















  • 2




    @movcmpret: no it won't. This is x86 with MASM-like syntax. The error is that symbol names magically get a size associated with them when declared that way, and mov ax, m1 is doing a word load from a byte "variable", and the assembler stops you from making that mistake. One solution is to use dw and make everything a word, or to use byte registers (al)
    – Peter Cordes
    Nov 11 at 17:26











  • I am a beginner in the assembly language, can you help me?
    – Faisal
    Nov 11 at 17:26










  • I just edited my last comment.
    – Peter Cordes
    Nov 11 at 17:27










  • I will trying now
    – Faisal
    Nov 11 at 17:34










  • I do it. But If i running the program I didn't now where i can see the result.
    – Faisal
    Nov 11 at 17:51













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I wrote this code, in assembly, to calculate (4*7)+5, but I get these errors:




(18) wrong parameters: MOV ax,m1

(18) operands do not match: 16 bit register and 8 bit address.




 .MODEL SMALL
.stack 100h
.data
m1 DB 4
m2 DB 7
m3 DB 5
m4 DB ?
.code
main PROC
mov ax,@data
mov ds,ax
mov ax,m1
mul ax,m2
add ax,m3
mov m4,ax

BEGIN ENDP
END main









share|improve this question















I wrote this code, in assembly, to calculate (4*7)+5, but I get these errors:




(18) wrong parameters: MOV ax,m1

(18) operands do not match: 16 bit register and 8 bit address.




 .MODEL SMALL
.stack 100h
.data
m1 DB 4
m2 DB 7
m3 DB 5
m4 DB ?
.code
main PROC
mov ax,@data
mov ds,ax
mov ax,m1
mul ax,m2
add ax,m3
mov m4,ax

BEGIN ENDP
END main






assembly x86-16






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 18:24









Peter Cordes

117k16178305




117k16178305










asked Nov 11 at 17:19









Faisal

113




113







  • 2




    @movcmpret: no it won't. This is x86 with MASM-like syntax. The error is that symbol names magically get a size associated with them when declared that way, and mov ax, m1 is doing a word load from a byte "variable", and the assembler stops you from making that mistake. One solution is to use dw and make everything a word, or to use byte registers (al)
    – Peter Cordes
    Nov 11 at 17:26











  • I am a beginner in the assembly language, can you help me?
    – Faisal
    Nov 11 at 17:26










  • I just edited my last comment.
    – Peter Cordes
    Nov 11 at 17:27










  • I will trying now
    – Faisal
    Nov 11 at 17:34










  • I do it. But If i running the program I didn't now where i can see the result.
    – Faisal
    Nov 11 at 17:51













  • 2




    @movcmpret: no it won't. This is x86 with MASM-like syntax. The error is that symbol names magically get a size associated with them when declared that way, and mov ax, m1 is doing a word load from a byte "variable", and the assembler stops you from making that mistake. One solution is to use dw and make everything a word, or to use byte registers (al)
    – Peter Cordes
    Nov 11 at 17:26











  • I am a beginner in the assembly language, can you help me?
    – Faisal
    Nov 11 at 17:26










  • I just edited my last comment.
    – Peter Cordes
    Nov 11 at 17:27










  • I will trying now
    – Faisal
    Nov 11 at 17:34










  • I do it. But If i running the program I didn't now where i can see the result.
    – Faisal
    Nov 11 at 17:51








2




2




@movcmpret: no it won't. This is x86 with MASM-like syntax. The error is that symbol names magically get a size associated with them when declared that way, and mov ax, m1 is doing a word load from a byte "variable", and the assembler stops you from making that mistake. One solution is to use dw and make everything a word, or to use byte registers (al)
– Peter Cordes
Nov 11 at 17:26





@movcmpret: no it won't. This is x86 with MASM-like syntax. The error is that symbol names magically get a size associated with them when declared that way, and mov ax, m1 is doing a word load from a byte "variable", and the assembler stops you from making that mistake. One solution is to use dw and make everything a word, or to use byte registers (al)
– Peter Cordes
Nov 11 at 17:26













I am a beginner in the assembly language, can you help me?
– Faisal
Nov 11 at 17:26




I am a beginner in the assembly language, can you help me?
– Faisal
Nov 11 at 17:26












I just edited my last comment.
– Peter Cordes
Nov 11 at 17:27




I just edited my last comment.
– Peter Cordes
Nov 11 at 17:27












I will trying now
– Faisal
Nov 11 at 17:34




I will trying now
– Faisal
Nov 11 at 17:34












I do it. But If i running the program I didn't now where i can see the result.
– Faisal
Nov 11 at 17:51





I do it. But If i running the program I didn't now where i can see the result.
– Faisal
Nov 11 at 17:51













1 Answer
1






active

oldest

votes

















up vote
2
down vote













Because all of the numbers involved 4,7,5 are very small, you get by with data definitions using db.
But this also means that the calculations should be byte-sized.



Write this instead:



mov al, m1
mul m2 ;Leaves m1 * m2 in AX (4*7=28 so AL=28 and AH=0)
add al, m3
mov m4, al


If you use a byte-sized operand (m2) with the mul instruction then AL is multiplied with it and the double-length product is stored in AX.






share|improve this answer




















  • Thank you.......
    – Faisal
    Nov 11 at 18:40










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
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',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251236%2foperands-do-not-match-assembler-syntax-error%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













Because all of the numbers involved 4,7,5 are very small, you get by with data definitions using db.
But this also means that the calculations should be byte-sized.



Write this instead:



mov al, m1
mul m2 ;Leaves m1 * m2 in AX (4*7=28 so AL=28 and AH=0)
add al, m3
mov m4, al


If you use a byte-sized operand (m2) with the mul instruction then AL is multiplied with it and the double-length product is stored in AX.






share|improve this answer




















  • Thank you.......
    – Faisal
    Nov 11 at 18:40














up vote
2
down vote













Because all of the numbers involved 4,7,5 are very small, you get by with data definitions using db.
But this also means that the calculations should be byte-sized.



Write this instead:



mov al, m1
mul m2 ;Leaves m1 * m2 in AX (4*7=28 so AL=28 and AH=0)
add al, m3
mov m4, al


If you use a byte-sized operand (m2) with the mul instruction then AL is multiplied with it and the double-length product is stored in AX.






share|improve this answer




















  • Thank you.......
    – Faisal
    Nov 11 at 18:40












up vote
2
down vote










up vote
2
down vote









Because all of the numbers involved 4,7,5 are very small, you get by with data definitions using db.
But this also means that the calculations should be byte-sized.



Write this instead:



mov al, m1
mul m2 ;Leaves m1 * m2 in AX (4*7=28 so AL=28 and AH=0)
add al, m3
mov m4, al


If you use a byte-sized operand (m2) with the mul instruction then AL is multiplied with it and the double-length product is stored in AX.






share|improve this answer












Because all of the numbers involved 4,7,5 are very small, you get by with data definitions using db.
But this also means that the calculations should be byte-sized.



Write this instead:



mov al, m1
mul m2 ;Leaves m1 * m2 in AX (4*7=28 so AL=28 and AH=0)
add al, m3
mov m4, al


If you use a byte-sized operand (m2) with the mul instruction then AL is multiplied with it and the double-length product is stored in AX.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 18:35









Sep Roland

11.6k21845




11.6k21845











  • Thank you.......
    – Faisal
    Nov 11 at 18:40
















  • Thank you.......
    – Faisal
    Nov 11 at 18:40















Thank you.......
– Faisal
Nov 11 at 18:40




Thank you.......
– Faisal
Nov 11 at 18:40

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • 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%2fstackoverflow.com%2fquestions%2f53251236%2foperands-do-not-match-assembler-syntax-error%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







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3