TITLE JIMMY
.MODEL SMALL
.STACK 100
.DATA
NUMERO1 DB(?)
NUMERO2 DB(?)
NEGAT DB "-$"
POSITIVO DB "+$"
NEGA DB(?)
MOLTIPLICAZIONE DB(?)
DIVISIONE DB(?)
SOMMA DB(?)
SOTTRAZIONE DB(?)
UNITA DB(?)
DECINE DB(?)
SCRITTURA1 DB "IMMETTI I DUE NUMERI $"
SCRITTURA2 DB "IL RISULTATO DELLA MOLTIPLICAZIONE E $"
SCRITTURA3 DB "IL RISULTATO DELLA DIVISIONE E $"
SCRITTURA4 DB "IL RISULTATO DELLA SOMMA E $"
SCRITTURA5 DB "IL RISULTATO DELLA SOTTRAZIONE E $"
.CODE
.STARTUP

MOV AH,9
MOV DX,OFFSET SCRITTURA1
INT 21H

MOV AH,1
INT 21H
MOV NUMERO1,AL

MOV AH,1
INT 21H
MOV NUMERO2,AL

MOV CL,NUMERO1
SUB CL,48
MOV NUMERO1,CL

MOV CL,NUMERO2
SUB CL,48
MOV NUMERO2,CL

MOV AL,NUMERO1
MUL NUMERO2
MOV MOLTIPLICAZIONE,AL

MOV AH,0
MOV CL,NUMERO1
MOV AL,CL
DIV NUMERO2
MOV DIVISIONE,AL

MOV CL,NUMERO1
ADD CL,NUMERO2
MOV SOMMA,CL

MOV CL,NUMERO1
SUB CL,NUMERO2
MOV SOTTRAZIONE,CL

MOV AH,9
MOV DX,OFFSET SCRITTURA2
INT 21H

MOV DL,SOMMA
MOV AL,DL
MOV AH,0
MOV CL,10
DIV CL
MOV DECINE,AL
MOV UNITA,AH

ADD DECINE,48
ADD UNITA,48

MOV AH,2
MOV DL,DECINE
INT 21H

MOV AH,2
MOV DL,UNITA
INT 21H

MOV AH,9
MOV DX,OFFSET SCRITTURA3
INT 21H

CMP NEGA,255
JNE POSITIVO
MOV AH,2
MOV DL,NEGA
INT 21H

MOV AH,2
MOV DL,SOTTRAZIONE
ADD DL,48
INT 21H

MOV AH,9
MOV DX,OFFSET SCRITTURA4
INT 21H

MOV DL,MOLTIPLICAZIONE
MOV AL,DL
MOV AH,0
MOV CL,10
DIV CL
MOV DECINE,AL
MOV UNITA,AH

ADD DECINE,48
ADD UNITA,48

MOV AH,2
MOV DL,DECINE
INT 21H

MOV AH,9
MOV DX,OFFSET SCRITTURA5
INT 21H

MOV AH,2
MOV DL,DIVISIONE
ADD DL,48
INT 21H

MOV AH,4CH
INT 21H

END

rproffitt commented: Dump code and run? -2

Dani AI

Generated

As posted by , the assembler message "Argument to operation or instruction has illegal size" normally points to an operand-size mismatch or an ambiguous memory operand. As suggested, single-stepping helps find a runtime fault, but the fastest way to pin an assembly-time error is to produce the assembler listing so the exact line and the operand sizes the assembler inferred are visible.

Common causes and quick examples:

  • Moving between registers of different widths (word vs byte).
  • Using a memory symbol without an explicit size so the assembler can't choose the right encoding.
  • Passing a word where an instruction expects a byte (or vice versa).
; illegal: destination and source sizes differ
mov ax, bl

; disambiguate memory operands
mov al,  BYTE PTR [myByte]
mov ax,  WORD PTR [myWord]

Multiplication and division are frequent culprits because they have strict size rules: MUL/IMUL with an 8-bit operand use AL as an implicit operand and store the result in AX; with a 16-bit operand they use AX and store result in DX:AX. DIV/IDIV expect the dividend in AX (for 8-bit divisors) or DX:AX (for 16-bit divisors), so AH/DX must be zeroed or sign-extended first. Example pattern:

; multiply two unsigned bytes -> AX = AL * [b]
mov al, [b1]
mul byte ptr [b2]   ; AX = AL * [b2]

; divide unsigned AX by a byte -> AL=quotient, AH=remainder
xor ah, ah
div byte ptr [b2]

Practical troubleshooting flow: build an assembler listing to get the exact flagged line and the operand sizes the assembler assumed; add BYTE PTR / WORD PTR where the size is ambiguous; check all MOV/ADD/SUB operands for matched sizes; prepare AX/DX correctly before DIV/MUL; and then single-step in a DOS debugger/emulator to confirm register contents at the failing instruction. If the error persists, the assembler listing with the flagged line is the most useful artifact for precise diagnosis.

Time to single step this one and post as Code again along with the line number that's creating the error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.