Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7501501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:33:24+00:00 2026-05-29T20:33:24+00:00

I’m starting to learn assembly language. The program I need to do is very

  • 0

I’m starting to learn assembly language. The program I need to do is very simple.
1 – Read a 4-digit number (can be a negative number)
2 – Output the number the entered number
3 – Calculate/Output the half of the entered number
4 – Calculate/Output the double of the entered number

So… this is the code… first, the data section

section .data ; Data segment
    msgPrompt       db 'Please enter a number ' ; Ask the user to enter a number
    lenMsgPrompt    equ $-msgPrompt          ; The length of the message
    msgNumber       db 'The entered number is '
    lenMsgNumber    equ $-msgNumber                 
    msgHalf         db 'The half of the entered number is '
    lenMsgHalf      equ $-msgHalf
    msgDouble       db 'The double of the entered numbered is '
    lenMsgDouble    equ $-msgDouble

Then the uninitialized data (for the user input)

section .bss        ; Uninitialized data
    userNumber    resb 5
    halfNumber    resb 5
    doubleNumber  resb 5

Then… the code segment…

    section .text       ; Code Segment

       global _start
       _start:

       ;Prompt the user
       mov eax, 4
       mov ebx, 1
       mov ecx, msgPrompt
       mov edx, lenMsgPrompt
       int 80h

       ; Read and store the user input
       mov eax, 3
       mov ebx, 2
       mov ecx, userNumber  
       mov edx, 5       ; 5 bytes (numeric, 1 for sign) of that information
       int 80h

       ; Output the message 'The entered number is '
       mov eax, 4
       mov ebx, 1
       mov ecx, msgNumber
       mov edx, lenMsgNumber
       int 80h  

       ; Output the number entered
       mov eax, 4
       mov ebx, 1
       mov ecx, userNumber
       mov edx, 5
       int 80h  

       ; Output the message 'The half of the entered number is '
       mov eax, 4   
       mov ebx, 1
       mov ecx, msgHalf
       mov edx, lenMsgHalf
       int 80h

       ; Calculate the half of the number entered
       mov eax, [userNumber]
       shr eax, 1       ; Shift to the right by one bit
       mov [halfNumber], eax

       ; Output half of the number entered
       mov eax, 4
       mov ebx, 1
       mov ecx, halfNumber
       mov edx, 5
       int 80h

       ; Output the message 'The double of the entered numbered is '
       mov eax, 4
       mov ebx, 1
       mov ecx, msgDouble
       mov edx, lenMsgDouble
       int 80h

       ; Calculate the double of the number entered
       mov ebx, [userNumber]
       shl ebx, 1       ; Shift the the left by one bit
       mov [doubleNumber], ebx

       ; Output double of the number entered
       mov eax, 4
       mov ebx, 1
       mov ecx, doubleNumber
       mov edx, 5
       int 80h

       ; Leave program
       mov eax, 1
       mov ebx, 0
       int 0x80

This is the final result… Here (I don’t have enough reputation yet to post images…)

As you can see, there is problem… Also, I would like to have a new line after ‘The half of the number is xxxxx’.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:33:26+00:00Added an answer on May 29, 2026 at 8:33 pm

    Looks like you’re doing arithmetic on ASCII codes for the digits, instead of the numeric value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.