Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 25th, 2005, 12:44 PM   #1
sheeba
Newbie
 
Join Date: Mar 2005
Posts: 8
Rep Power: 0 sheeba is on a distinguished road
Doubling numbers

Hi , I need some help with this program
I've tried figureing out myself for the last 2 days but can't.
After the user enters a number , that number is supposed to be doubled and displayed , doubled & displayed again , in the loop 5 times.

thanks

.model small
.stack 100h
.data
input db 0dh,0ah,"Please type an integer between 1-1000h:",0
two dw 2h
.code
extrn Writeint:proc,Writestring:proc,Readint:proc,Crlf:proc
main proc
   mov ax,@data
   mov ds,ax
   mov cx,5
   mov dx,offset input
   call Writestring
   call Readint
   call Crlf
   mov bx,16
   call Writeint
   next:
     mul two
     mov bx,16
     call Writeint
   loop next
   mov ax,4c00h
   int 21h
 main endp
 end main
sheeba is offline   Reply With Quote
Old Mar 25th, 2005, 3:44 PM   #2
brkstf
Programmer
 
brkstf's Avatar
 
Join Date: Feb 2005
Posts: 89
Rep Power: 4 brkstf is on a distinguished road
the cool way to do this is to shift the register to the left. no need to multiply by two.
brkstf is offline   Reply With Quote
Old Mar 25th, 2005, 5:28 PM   #3
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
What seems to be wrong with your code?
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Mar 25th, 2005, 6:23 PM   #4
sheeba
Newbie
 
Join Date: Mar 2005
Posts: 8
Rep Power: 0 sheeba is on a distinguished road
Thanks for the replies.
It compiles , links , & when I try to run it , & type a number , & press enter the dos window shuts down ??
sheeba is offline   Reply With Quote
Old Mar 25th, 2005, 6:24 PM   #5
sheeba
Newbie
 
Join Date: Mar 2005
Posts: 8
Rep Power: 0 sheeba is on a distinguished road
How would I do that brkstff?
sheeba is offline   Reply With Quote
Old Mar 25th, 2005, 7:24 PM   #6
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
There should probably be a shl instruction for whatever assembler you may be using. It works because -- well, think about it, the bit to the left is double the current bit. Take this example:

The value five has this binary representation:

101

you shift left and you get

1010

which is 10

shift left again and you get 20

10100
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Mar 26th, 2005, 12:39 AM   #7
sheeba
Newbie
 
Join Date: Mar 2005
Posts: 8
Rep Power: 0 sheeba is on a distinguished road
Thanks im going to work on it , see if I can figure it out
sheeba is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:58 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC