How many times you thought to print result stored in a register to print on screen. This is rather difficult but there is no built in feature to print value stored in a register to screen(like printf("%d") in c).
So i have wrote a code to print result on screen. You can put this code in a separate
subroutine and you can call it any where in your program.
You know that only array of ASCII values can be print on screen by interrupt 21h.
I have just converted a number into ASCII string to print it.
So following is the code I wrote.
numberToBePrint dw 9870
charArray db 10 DUP('$')
;setting ax register to ziro
;assigning number to be print on screen
;divide ax by 10, remainder of divide will store in dx
;assigning address of first block of charArray to di register
mov di,offset charArray
;assigning remainder in first block of char array
;changing numeric number into its ascii equivalent.
;by adding 48 to its value, 48 is ascii code of 0
;increment di to point to next block of array.
;logic for swaping array element to next block
;if current block contains 0 then get out from loop
;clearing remainder from dx
;checking ax for 0, if ax is 0 then get out from loop
;printing char array on the screen
mov dx, offset charArray
;9 is the interrupt service number used for screen display
;calling dos for printing characters starting from location stored in dx
;waiting for a key press.
;exit from program