L
L
LoooSee2019-10-09 20:44:38
assembler
LoooSee, 2019-10-09 20:44:38

I deal with multiplication in assembler, why does it work this way, but not like that?

Here, as expected in dx : ax is written the correct result of the multiplication. Code 16 bit

use16
mov ax,3h
mov bx,4h
mul bx

And here the program breaks during execution. The code is already 32 bit, changed only 16 to 32
use32
mov ax,3h
mov bx,4h
mul bx

Is it possible that something does not fit somewhere, although this is very strange, because the bit depth is greater. If for 32 bits you need to somehow multiply and divide differently, can you tell me where to read about it? I can't find it in my book or on the internet.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2019-10-09
@fox_12

If you switch to 32 bits, then you already need to operate with the eax and ebx registers:

mov eax,3h
mov ebx,4h
mul ebx

otherwise, who knows what kind of garbage you store in the high bits of the registers

J
jcmvbkbc, 2019-10-09
@jcmvbkbc

program crashes during execution

How does it break?
use32
mov ax,3h
mov bx,4h
mul bx

should write 12 to ax and 0 to dx and clear the OF and CF flags. What is recording?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question