Wednesday, October 30, 2013

8-bit Subtraction register adddressing mode with borrow

;8-bit Subtraction register adddressing mode with borrow

 .8086
 .model small
 .data
 num1 db 0ah
 num2 db 0Fh
 ans db ?
 carry db ?
 .code
 Start:
 mov ax , @data                 ; Copying the address of the data to AX.
 mov ds , ax
 mov ax , 0000h
 mov al , num1                  ; Copies Num1 to AL.
 mov bl , num2
 sub al , bl                    ;Subtracts BL fron AL.

 mov ah , 00h
 mov ans,al

 lahf                           ;Loads all the flags to AH.
 AND ah,01h

 mov carry , ah
 mov ax , 4c00h
 int 21h
 end start

 ;Result
 ;DS:0000 0A(NUM1)
 ;DS:0000 0F(NUM2)
 ;ds:00008 0FA(ans)
 ;ds:00008 01 (ans)

No comments:

Post a Comment