Why is my assembly output in letter position? (1+1=b)

前端 未结 1 1672
遇见更好的自我
遇见更好的自我 2021-01-21 18:54

I am using tasm. It is a simple program that reads the inputs from user and add the two numbers up. However, my output is displaying letters according to their letter position

1条回答
  •  天命终不由人
    2021-01-21 19:37

    Your input digits are ASCII characters, so ‘1’ is actually 31h, for example. So when you calculate 1+1 your are getting 31h+31h=62h which is the ASCII character ‘b’.

    To convert your input digits to their equivalent integer values you need to subtract ‘0’ (30h).

    Conversely to output integer digits as ASCII characters you will need to add ‘0’.

    0 讨论(0)
提交回复
热议问题