Problem converting integer to ASCII code in x86 assembly

一笑奈何 提交于 2019-12-02 11:16:09

SI is not initialized. It should point to a buffer allocated for the reverse order digits.

old_timer

Your divide loop looks good

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

 int main ( void )
 {
     unsigned int ax;
     unsigned int dx;

     ax=513;

     while(ax)
     {
        dx=ax%10;
        ax=ax/10;
        printf("%c",dx+0x30);
     }
     printf("\n");
 }

I get 315 out of the above loop.

I suspect when you try to flip the string around your 5 is stomping on your 3. Try a number like 713 and see if it results in 717. 523 if you get 525, etc. I am guessing 1234 results in 4334.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!