I'm very new to assembly programming, mostly just trying to learn from youtube videos and the "assembly language for x86 processors" pdf. the program is no where near completion now, but I'm already getting 3 errors I can't figure out.
Symbol type conflict (line 15)
.model small
.data
message db "Please enter a for mutiplication or b for division $"
message2 db " Enter the first number $"
message3 db " Enter the second number $"
message4 db " * $"
message5 db " / $"
message6 db " = $"
.code
main proc
mov ax, seg message
mov ds, ax
mov dx, offset message
mov ah, 9h
int 21h
mov ah, 1h ;input stored in al
int 21h
mov bl, al ; menu selection input stored in bl so al can be used freely
mov ah, seg message2
mov ds, ah
mov dx, offset message2
mov ah, 9h
int 21h
mov ah, 1h; input stored in al
int 21h
mov cl, al ; first number input stored in cl so al can be used freely
mov dl, bl
mov ah, 2h
int 21h
mov dl, al ;second number imput stored in dl so al can be used again
sub cl, 30h ;convert characters to decimal
sub dl, 30h
mov ax, cl ;preform division
div dl
mov al, cl ;preform multiplication
mul dl
add cl, 30h ; convert decimal back to the characters
add dl, 30h
main endp
end main
eventually I want to limit the range of inputs to 1-100 and I'd appreciate any tips on how to do that also, any help would be appreciated
I couldn't reproduce here the errors 1) and 3). Maybe they are "gone" with copying. Delete the lines in the source and type them again.
"error A2070:invalid instruction operands":
1) Lines 27 and 26:
mov ah, seg message2
mov ds, ah
A segment is a 16-bit value. You cannot load it into an 8-bit register (AH
). Furthermore, you cannot copy an 8-bit register (AH
) to a 16-bit register (DS
). Change the lines to:
mov ax, seg message2
mov ds, ax
2) Line 46:
mov ax, cl ;preform division
div dl
You cannot copy an 8-bit register (CL
) to a 16-bit-register (AX
). There are special instructions to perform such a thing: MOVZX
& MOVSX
. The first instruction treats the 8-bit register as an unsigned integer, the second as signed integer. Change the lines to:
movzx ax, cl ;preform division
div dl
An "ancient" 8086 way is:
xor ch, ch ; set CH (the upper part of CX) to null
mov ax, cx ;preform division
div dl