Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 4th, 2004, 10:59 AM
Registered User
Join Date: Feb 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need some help in Aseembly Language programming

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.

TITLE Add individual digits of a number ADDIGITS.ASM
        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.
number_prompt DB 'Please type a number (<11 digits): ',0
out_msg DB 'The sum of individual digits is: ',0
number DB 11 DUP (?)

INCLUDE io.mac
main PROC
        PutStr number_prompt ; request an input number
        GetStr number,11 ; read input number as a string
        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
        add DL,AL ; add the digit to sum
        inc BX ; increment BX to point to next digit
        jmp repeat_add ; and jump back
        PutStr out_msg
        PutInt DX ; write sum
main ENDP
        END main
Old February 4th, 2004, 02:53 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

See this thread.

Work smarter, not harder.
Old March 25th, 2004, 07:46 AM
Authorized User
Join Date: Jun 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to HuhOiC

I might be able to help. I took a course on Assembly and MIPS. I don't quite understand what you mean by having invalid input. What would you like it to do if they enter invalid characters? So you have to check and not assume they enter valid characters? Will the user enter 4 or can they do more or less?

you know the logic though right? Here's a little hint. starting with the least signinificant bit. Let 0 be represent that, by a variable. Raise 16 to that power and mulitply it by the number there. you need to convert letters A-F to be 10-15 respectively.

Seeing as this sounds like a homework, you might not be interested in getting back to me,since it was probably due. But if your still interested email me. I can help you out.

Huh O i C

Program or Be Programmed!!!

Similar Threads
Thread Thread Starter Forum Replies Last Post
software of c++ programming language jhanny007 C++ Programming 17 December 22nd, 2006 09:23 AM
Programming Language holi4him Intro Programming 2 July 25th, 2006 07:42 AM
which programming language do i choose? hnz Wrox Book Feedback 5 May 13th, 2005 05:58 AM
The most favourite programming language tot2ivn Wrox Book Feedback 2 July 30th, 2004 01:09 AM
Change Programming Language ritag ADO.NET 6 June 16th, 2004 04:06 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.