打印号码到屏幕组件 [英] print number to screen assembly

查看:67
本文介绍了打印号码到屏幕组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将寄存器中的数字打印到屏幕上.此外,我想将其另存为字符串(字节).因此,如果我有一个像150这样的数字,我想将其保存在某个地址为

I want to print a number in a register to the screen. Furthermore I want to save it as a string of characters (bytes). So if I had a number like 150, I would want to save it at a certain address as

"1","5","0"

'1', '5', '0'

mov ebx, dword ptr[ebp+8]
; eax contains value
; ebx contains address to store characters

; here is where conversion would take place

由于它在寄存器中,您是否需要将其转换为十进制值,然后将每个位置分开?

Since it's in a register, would you have to convert it to decimal value and then separate each place?

推荐答案

我不确定如何打印ASCII码以及如何分隔每个位置.因此,我只想展示如何将EAX的值转换为十进制ASCII并将其存储到DS:EBX的地址.对于最大0FFFFFFFFh的32位值,我们需要一个十位十进制ASCII(4294967295)的位置.例如,如果该值为十进制150,那么我们得到的ASCII码为"0000000150",开头是"0".

I´am not sure how to print the ASCII's and how to separate each place. And so i only like to show how to convert the value of EAX to decimal ASCII's and store it to the address of DS:EBX. For a 32 bit value of maximum 0FFFFFFFFh we need a place for ten decimal ASCII's (4294967295). And for example if the value is decimal 150, then we get the ASCII's of "0000000150" with some "0" at the beginning.

      mov     cl, 0Ah             ; counter for ten decimal ASCII's
      mov     edi, 1000000000
P1:   xor     edx, edx
      div     edi
      add     al, 30h             ; convert to ASCII
      mov     esi, edx            ; save remainder
      mov     [ebx], al           ; store ASCII to the address of DS:EBX
      inc     ebx
      mov     eax, edi
      mov     edi, 0Ah
      xor     edx, edx
      div     edi
      mov     edi, eax
      mov     eax, esi
      dec     cl
      jnz P1

这篇关于打印号码到屏幕组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆