how do i include subtraction, multiply and divide in my code in FASM? -


format mz entry code:start

segment ddata  num1 db ?  num2 db ?  result db ?  msg1 db 10,13,"enter first number add : $"  msg2 db 10,13,"enter second number add : $"  msg3 db 10,13,"result of addition : $" 

segment code start:

  mov ax, ddata   mov ds,ax    lea dx, [msg1]   mov ah,9   int 21h    mov ah,1   int 21h   sub al,30h   mov [num1], al    lea dx, [msg2]   mov ah,9   int 21h    mov ah,1   int 21h   sub al,30h   mov [num2] ,al    add al, [num1]    mov [result], al    mov ah,0   aaa    add ah,30h   add al,30h    mov bx,ax    lea dx, [msg3]   mov ah,9   int 21h    mov ah,2   mov dl,bh   int 21h    mov ah,2   mov dl,bl   int 21h    mov ah,4ch   int 21h 

https://www.pdf-archive.com/2016/11/25/fasm/

subtraction:

sub    al,1 

sub subtracts source operand destination operand , replaces destination operand result. if borrow required, cf set. rules operands same add instruction.

multiply:

mul    bx 

mul performs unsigned multiplication of operand , accumulator. if operand byte, processor multiplies contents of al , returns 16–bit result ah , al. if operand word, processor multiplies contents of ax , returns 32–bit result dx , ax. if operand double word, processor multiplies contents of eax , returns 64–bit result in edx , eax. mul sets cf , of when upper half of result nonzero, otherwise cleared.

divide:

div bx 

div performs unsigned division of accumulator operand. dividend (the accumulator) twice size of divisor (the operand), quotient , remainder have same size divisor. if divisor byte, dividend taken ax register, quotient stored in al , remainder stored in ah. if divisor word, upper half of dividend taken dx, lower half of dividend taken ax, quotient stored in ax , remainder stored in dx. if divisor double word, upper half of dividend taken edx, lower half of dividend taken eax, quotient stored in eax , remainder stored in edx. rules operand same mul instruction.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -