0

I am using this call to test a question in my assignment. I am new to assembly language.

INCLUDE PCMAC.INC
       .MODEL SMALL
       .586
       .STACK 100H
.DATA
lfc     DW  1892
ger DB  8

.CODE
EXTRN GetDec:Near,PutDec:Near
start       PROC
            _Begin
            mov ax, lfc
            mul ger
            call PutDec
            _Exit 0

start       ENDP 
            END start

I am expecting PutDec to display 15136, but my output is 800. What am I doing wrong?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • 4
    Recall that this `mul` is a byte-sized multiplication because `ger` is a byte-sized operand. It'll multiply `AL` with `get` producing output in `AX`. The contents of `AH` are ignored. – fuz Jan 28 '21 at 21:33
  • I see now! Thanks, changing `ger` to `DB` solved the issue. – Akash Digumber Jan 28 '21 at 21:41
  • Is this 32-bit code (`.586`)? If so, PutDec probably expects a value in the full EAX, and MUL writing AL leaves the upper half unmodified (and thus possibly holding garbage) – Peter Cordes Jan 29 '21 at 01:46
  • Near duplicate: [is this the right way to use cbw in Mul?](https://stackoverflow.com/q/55645909) – Peter Cordes Jan 29 '21 at 01:48

0 Answers0