![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2005
Posts: 8
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Feb 2005
Posts: 89
Rep Power: 4
![]() |
the cool way to do this is to shift the register to the left. no need to multiply by two.
|
|
|
|
|
|
#3 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
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 |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Mar 2005
Posts: 8
Rep Power: 0
![]() |
Thanks for the replies.
It compiles , links , & when I try to run it , & type a number , & press enter the dos window shuts down ?? |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Mar 2005
Posts: 8
Rep Power: 0
![]() |
How would I do that brkstff?
|
|
|
|
|
|
#6 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
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 |
|
|
|
|
|
#7 |
|
Newbie
Join Date: Mar 2005
Posts: 8
Rep Power: 0
![]() |
Thanks im going to work on it , see if I can figure it out
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|