Write assembly language to add two decimal number?

1 answer

Answer

1186864

2026-05-12 08:40

+ Follow

name "str2bin"

; convert string number to binary!

; this program written in 8086 assembly language to

; convert string value to binary form.

; this example is copied with major modifications

; from macro "scan_num" taken from c:\emu8086\inc\emu8086.inc

;

; the original "scan_num" not only converts the string number

; but also reads the string from the keyboard and supports

; backspace key, this example is a shorten version

; of original "scan_num" macro.

; here we assume that the string number is already given,

; and the string number does not contain non-digit chars

; and it cannot cause buffer overflow (number is in Word range

; and/or has only 4 digits).

; negative values are allowed in this example.

; the original "scan_num" does not allow to enter non-digits

; and it also checks for buffer overflow.

; you can the original file with other macro definitions

; in c:\emu8086\inc\emu8086.inc

org 100h

jmp start

; text data:

msg1 db 0Dh,0Ah, " enter any number from -32768 to 65535 inclusive, or zero to stop: $"

msg2 db 0Dh,0Ah, " binary form: $"

; buffer for int 21h/0ah

; fist byte is buffer size,

; second byte is number of chars actually read (set by int 21h/0ah).

buffer db 7,?, 5 dup (0), 0, 0

; for result:

binary dw ?

start:

; print welcome message:

mov dx, offset msg1

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.