•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 391,596 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,656 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser:
Views: 553 | Replies: 0
![]() |
•
•
Join Date: May 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Can you tell me what needs to be changed in the program in order to run? Thank you.
.model small
.386
.stack 100h
.data
.code
decimal proc near
;print out number given in AX in decimal
xor eax,eax
xor ebx,ebx
mov cx,2 ;this is to accept the base and the decimal value
newchar:
cmp cx,0
jle startConvert
dec cx
mov ah,1 ;This sets up to accept another input from keyboard
int 21h ;this asks for an input and stores it in al
;mov al,0h ;This sets up to accept another input from keyboard
;int 21h ;this asks for an input and stores it in al
;push ax ;stores the second input from keyboard
sub al,30h
jl stloop ;jumps if negative
cmp al,9h
jg stloop ;jumps if greater than
xor ah,ah ;to get only the digit they type
push ax ;this stores the first input from the keyboard
cbw ;convert byte to word
;jmp newchar ;to accept multiple digits
stloop:
mov ah,2
mov dl,0ah
int 21h ;This section inserts a carrige return
mov dl,0dh
int 21h
startConvert: pop bx
push ax ;given to routine to print out
;push bx
push cx
push dx
mov cx,0 ;starts a counter for the number of digits
;mov bx,10 ;base 10 conversion THIS IS THE LINE TO CHANGE FOR DIFFERENT BASES!!!!
nonzero:
xor dx,dx ;same as mov dx,0
div bx
push dx ;this is the remainder of the divider
inc cx ;this will help determine the number of digits produced
or ax,ax ;sets flags to check is ax = 0
jne nonzero ;jump not equal to
write:
pop dx ;gets deciaml digit from stack
add dl,'0' ;ascii value of 30h (what are the values for octal and binary)
mov ah,2
int 21h
loop write ;loops number of times in cx, which is the number of digits
pop dx
pop cx
pop bx
pop ax
ret
decimal endp
end decimal Last edited by Narue : May 5th, 2008 at 1:43 pm. Reason: Fixed tags
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Assembly Marketplace
Similar Threads
- memory management in wndows 2000 (Windows NT / 2000 / XP / 2003)
- Having trouble ENCODING/DECODING ASSEMBLY (Assembly)
- Assembler n00b. Need Help Please. (Assembly)
- convert number base (Assembly)
Other Threads in the Assembly Forum
- Previous Thread: Program to read a line and count occurence of each letter and punctuation
- Next Thread: Writting a game code


Linear Mode