HDIVIDEND DW 1234H
LDIVIDEND DW 5678H
DIVISOR DW 1234H
MOV AX,LDIVIDEND
MOV DX,HDIVIDEND
DIV DIVISOR
I am getting an "Illeagal instruction" on running a masm code at the instruction
DIV DIVISOR
Where HDIVIDEND is the higher order bytes of dividend in 16 bit. And divisor is 16 bit.
Yes, the program you had written should have assembled correctly. Perhaps you had made a mistake in another part of your file, which would thus be the cause of your "illegal instruction". Or maybe you should download a newer version of MASM as it might have temporarily malfunctioned. Anyway, here is the working code, assembled and linked with MASM64 for Windows (should still work with MASM32):
dseg segment para 'DATA'
hdividend dw 1234h
ldividend dw 5678h
divisor dw 1234h
dseg ends
cseg segment para 'CODE'
start proc
mov ax, ldividend
mov dx, hdividend
div divisor
start endp
cseg ends
end
And the output:
C:\Masm64>bin\ml64.exe /c division.asm
Microsoft (R) Macro Assembler (x64) Version 8.00.50727.215
Copyright (C) Microsoft Corporation. All rights reserved.
Assembling: division.asm
C:\Masm64>bin\link.exe /subsystem:windows /entry:start division.obj
Microsoft (R) Incremental Linker Version 8.00.50727.215
Copyright (C) Microsoft Corporation. All rights reserved.
Hope this helps.