Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting Hexadecimal/Decimal numbers (Assemly-TASM)
    primarykey
    data
    text
    <p>I am trying to print the numbers simply in the sequence i.e</p> <p>1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20</p> <p>using Loop, First i converted each number into Hexa printed it reset it to the decimal increment by 1 and then print the next until the number is equal to 9, When the number is equal to 9 i used DAA to simply the number and after rotating and shifting the number i eventually stored the result in the string.</p> <p>The output is just fine till the 16, but after 16 the sequence repeats itself,</p> <p><strong>Desired output:</strong></p> <p>1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20</p> <p><strong>Current Output</strong> 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,11,12,13,14,15</p> <p>Why does it happens so ???</p> <p>Here is my Code,</p> <pre><code>MOV CX,20 ;Number of Iterations MOV DX,1 L1: PUSH DX ADD DX,30H MOV AH,02H ;PRINT Content of DX INT 21H POP DX ADD DX,1 CMP DX,09d ;If number is Greater than 9 jump to L2 JA L2 LOOP L1 L2: PUSH DX MOV AX,DX DAA ;Convert to the Decimal XOR AH,AH ;SET AH to 0000 ROR AX,1 ROR AX,1 ROR AX,1 ROR AX,1 SHR AH,1 SHR AH,1 SHR AH,1 SHR AH,1 ADC AX,3030h MOV BX,OFFSET Result MOV byte ptr[BX],5 ; Length of the String MOV byte ptr[BX+4],'$' ;5th position of string , $=Terminator MOV byte ptr[BX+3],AH ;2nd Number onto 4th position MOV byte ptr[BX+2],AL ;3rd number onto 3rd Position MOV DX,BX ADD DX,02 ;1st 2 positions of String are type of string and length respectively MOV AH,09H ;to print the string INT 21H POP DX ADD DX,1 LOOP L2 MOV AH,4CH ;Return control to the DOS INT 21H </code></pre> <p>P.S: I took help from this chart in understanding the numbers.</p> <p><a href="http://www.cheat-sheets.org/saved-copy/ascii.png" rel="nofollow">http://www.cheat-sheets.org/saved-copy/ascii.png</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload