February 4th, 2004, 12:34 PM
 GTguy Registered User Join Date: Feb 2004 Posts: 3 Thanks: 0 Thanked 0 Times in 0 Posts

Hello Everybody

This is my first time writing on here so I will do my best to describe my two problems.

A) I have to make up a program that would change a hexadecimal number of length 4 (e.g. A10F) and change it into decimal form (e.g. 41231)

B) Using the addigits.asm file i have to change to read the string even if other characters are put in by the user (e.g. r6lk72Ã? would be equal to 15)

I have included the addigits.asm file below. If you could help or give me any clue on how to solve these i would really appreciate it.

COMMENT |
Objective: To find the sum of individual digits of
a given number. Shows character to binary
conversion of digits.
Input: Requests a number from keyboard.
| Output: Prints the sum of the individual digits.
.MODEL SMALL
.STACK 100H
.DATA
number_prompt DB 'Please type a number (<11 digits): ',0
out_msg DB 'The sum of individual digits is: ',0
number DB 11 DUP (?)

.CODE
INCLUDE io.mac
main PROC
.STARTUP
PutStr number_prompt ; request an input number
GetStr number,11 ; read input number as a string
nwln
mov BX,OFFSET number ; BX := address of number
sub DX,DX ; DX := 0 -- DL keeps the sum
mov AL,[BX] ; move the digit to AL
cmp AL,0 ; if it is the NULL character
je done ; sum is done
and AL,0FH ; mask off the upper 4 bits