“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
assembly x86-16
|
show 8 more comments
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
assembly x86-16
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, andmov ax, m1
is doing a word load from a byte "variable", and the assembler stops you from making that mistake. One solution is to usedw
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
|
show 8 more comments
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
assembly x86-16
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
assembly x86-16
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, andmov ax, m1
is doing a word load from a byte "variable", and the assembler stops you from making that mistake. One solution is to usedw
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
|
show 8 more comments
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, andmov ax, m1
is doing a word load from a byte "variable", and the assembler stops you from making that mistake. One solution is to usedw
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
|
show 8 more comments
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
.
Thank you.......
– Faisal
Nov 11 at 18:40
add a comment |
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
.
Thank you.......
– Faisal
Nov 11 at 18:40
add a comment |
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
.
Thank you.......
– Faisal
Nov 11 at 18:40
add a comment |
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
.
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
.
answered Nov 11 at 18:35
Sep Roland
11.6k21845
11.6k21845
Thank you.......
– Faisal
Nov 11 at 18:40
add a comment |
Thank you.......
– Faisal
Nov 11 at 18:40
Thank you.......
– Faisal
Nov 11 at 18:40
Thank you.......
– Faisal
Nov 11 at 18:40
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 usedw
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