简体   繁体   English

使用 MASM 在 8086 中添加两个 8 位数字

[英]Addition of two 8-bits number in 8086 using MASM

This is the code that I have written in 8086 using MASM.这是我使用 MASM 在 8086 中编写的代码。 The code is for simple addition of two 8-bit numbers (no need to worry about carry).该代码用于简单地将两个 8 位数字相加(无需担心进位)。 I gave for input to the following program, two numbers: 31h and 16h .我为以下程序输入了两个数字: 31h 和 16h 。 The output should have been 47h but it is giving me the output as 'w'.输出应该是 47h,但它给我的输出是“w”。 The code works fine if I take numbers whose some does not exceed 9, can someone please point out my mistake here?如果我取一些不超过 9 的数字,代码工作正常,有人可以在这里指出我的错误吗?

CODE:代码:

data segment
   n1 db 31h
   n2 db 16h
data ends

code segment
 assume cs:code, ds:data
  start:

   mov ax,data
   mov ds,ax

   mov al,n1
   mov bl,n2
   add al,bl

   add al,30h
   mov dl,al

   mov ah,02h
   int 21h

   mov ah,4ch
   int 21h

code ends
end start

After you add the two constants you wanted, you add al,30h , giving you a value of 77h .添加所需的两个常量后, add al,30h ,得到的值为77h This is the ASCII code for w , which you then print as an ASCII character rather than a number.这是w的 ASCII 代码,然后将其打印为 ASCII 字符而不是数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM