x86 - Assembly 386: Unexpected output when using Interrupt 21h with function 02h -
i'm beginning today assembly (i386) , i'm trying output caracters of 2-digits number. way found after resarch divide number 10d remainder , quotient , use interruption 21h function 02h output separately 2 digits.
my problem code below i'm expecting 53 output have 55. looks value stored in al register modified (i made try using variables store quotient , remainder , output correct in case). want understand why don't have expected output code below.
am doing wrong? can explain me in details please? moreover, regarding performances, can confirm me better use registers rather storing quotient , remainder in variables.
.386 code segment use16 assume cs:code, ds:code, ss:code org 100h ;offset décalés de 100h=256 label1: ;division quotient , remainder mov ax, 35d div divisor ;if divider byte ;the quotient stored on al register ;and residue on ah add ah, 30h add al, 30h ;displays first caracter (from right of string) mov dl, ah mov ah, 02h int 21h ;displays second character (from right of string) mov dl, al mov ah, 02h int 21h ret divisor db 10d code ends end label1
yes, if recall correctly, int 21h, , interrupt allowed , indeed overwrite of registers ax, cx, , dx.
your simplest work-around
push ax ;displays first caracter (from right of string) mov dl, ah mov ah, 02h int 21h pop ax ;displays second character (from right of string) mov dl, al mov ah, 02h int 21h
Comments
Post a Comment