•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 426,575 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 1,658 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: Programming Forums
Views: 10381 | Replies: 7
![]() |
•
•
Join Date: Nov 2006
Posts: 99
Reputation:
Rep Power: 2
Solved Threads: 1
•
•
•
•
hi guys, I just wanna learn how to convert from ASCII character to the value e.g. input X then the output is 10 etc.
anyone know please help
thanks :lol:
xor ah,ah
int 16h ;read in ascii character ( in range '0' - '9' ) into al
sub al, 48 ;convert ascii character to integer in range 0-9
•
•
Join Date: Nov 2006
Posts: 99
Reputation:
Rep Power: 2
Solved Threads: 1
It's not that complicated. Ascii characters are represented by numbers, so that, for example:
mov al, 'A' ;actually moves the number 65 into al, because that's its ascii code
mov al, 'B' ;actually moves the number 66 into al
mov al, C' ;moves 67 into al, and so on.
In the case of the numerals it's:
mov al, '0' ;moves the number 48 into al
mov al, '1' ;moves the number 49 into al
mov al, '2' ;moves the number 50 into al
mov al, '3' ;moves the number 51 into al
So if you subtract 48 from any of those four, you get 0, 1, 2 and 3 respectively - the conversion you want.
mov al, 'A' ;actually moves the number 65 into al, because that's its ascii code
mov al, 'B' ;actually moves the number 66 into al
mov al, C' ;moves 67 into al, and so on.
In the case of the numerals it's:
mov al, '0' ;moves the number 48 into al
mov al, '1' ;moves the number 49 into al
mov al, '2' ;moves the number 50 into al
mov al, '3' ;moves the number 51 into al
So if you subtract 48 from any of those four, you get 0, 1, 2 and 3 respectively - the conversion you want.
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,184
Reputation:
Rep Power: 38
Solved Threads: 930
•
•
•
•
thanks so much for your help
but I know how to declares the character already .. the problem is how to get the program working
Where is your code? What have you tried? People here are not mind readers, so you need to post YOUR code. And please use code tags as described in the links in my signature.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
•
•
Join Date: Nov 2006
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
thanks for your reply 
here the code

here the code
start:
read A0
push A0 ; save A0
push A1 ; save A1
load_fp A1 8 ; load parameter C
; compare to ASCII I to M
load_c A0 73 ; ASCII I
subtract A1 A0 ; A1 = int(C)
jmpn A1 outof
move A1 A0 ; copy it
load_c A1 M ; max value
subtract A1 A0 ; A1 = M - int(C)
jmpn A1 outof
; return result
store_fp A0 6 ; result
endDA: ; restore accumulators
pop A1
pop A0
return
outof: ; return -ve
store_fp A1 6 ; -ve
jump endDA
I: .data 2 73
V: .data 2 86
X: .data 2 88
L: .data 2 76
C: .data 2 67
D: .data 2 68
M: .data 2 77 Last edited by TheFuture : Nov 28th, 2006 at 2:13 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Assembly Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- display the number of capitals letters in the sentence (Assembly)
- Stuck on a program I am working on, converting a ASCII charchter to 7 Bit (Assembly)
Other Threads in the Assembly Forum
- Previous Thread: find files of certain type...
- Next Thread: Encryption/Decryption in LC-3, need some help



Linear Mode