0

I am trying to write a NASM program to multiply 2 8-bit numbers but i am not getting answers beyond 15. I am a beginner and i really dont its real working... Please help...

section .data
msg1:db "Enter the numbers:"
len1:equ $-msg1
msg2:db "Product is: "
len2:equ $-msg2

section .bss
a:resb 2
b:resb 2
p1:resb 1
p2:resb 1

section .text
global _start
_start:mov eax,4
   mov ebx,1
   mov ecx,msg1
   mov edx,len1
   int 80h

   mov eax,3
   mov ebx,0
   mov ecx,a
   mov edx,2
   int 80h

   mov eax,3
   mov ebx,0
   mov ecx,b
   mov edx,2
   int 80h

   mov eax,4
   mov ebx,1
   mov ecx,msg2
   mov edx,len2
   int 80h

   clc
   mov ecx,4
   mov al,[b]
   sub al,'0'
   mov ah,[a]
   sub ah,'0'
   shl ah,4
back:mov bl,al
     and bl,01h
     jz ahead
     add al,ah
 ahead:ror al,1
       loop back
       and eax,0000000fh
       daa
       mov ebp,eax
       and eax,000000f0h
       shr eax,4
       add eax,'0'
       mov [p1],eax
       mov eax,4
       mov ebx,1
       mov ecx,p1
       mov edx,1
       int 80h

       mov eax,ebp
       and eax,0000000fh
       add eax,'0'
       mov [p2],eax

       mov eax,4
       mov ebx,1
       mov ecx,p2
       mov edx,1
       int 80h

       mov eax,1
       mov ebx,0
       int 80h          

Most of the code is actually copied. And there is not much found on the internet about NASM programs

Michael
  • 57,169
  • 9
  • 80
  • 125
VPR
  • 165
  • 2
  • 9
  • 1
    _"there is not much found on the internet about NASM programs"_ There's tons about x86 assembly, which is what you're assembling with NASM. If your problem is related to some NASM-specific syntax then you can probably find the answer in [the NASM manual](http://www.nasm.us/doc/). – Michael Feb 18 '16 at 10:29
  • 2
    And I don't see anything in your question that explains why you're not using the `mul` instruction. – Michael Feb 18 '16 at 10:32
  • 1
    -1 for a big code-dump of uncommented code with no explanation of how your code is supposed to work. I see some ASCII character constants, and a rotate?!? At least it's indented nicely. But it mostly looks like DOS system calls. If you separated out the part that is supposed to multiply, that might help. – Peter Cordes Feb 18 '16 at 11:24

0 Answers0