| | |
print corresponding ascii for letters
![]() |
•
•
Join Date: Jan 2007
Posts: 9
Reputation:
Solved Threads: 0
Assembly Syntax (Toggle Plain Text)
; Description: Program to input a character and then output it to the screen ; Registers used: ax, dx .model small .stack 100h .data .code mov ah, 02h ; DOS function call 2, character output mov dl, 41h ; the character 041h (i.e.'A') mov cx, 26 ; start the counter at 26 in cx again: int 21h ; print character inc dl ; the next character into dl loop again ; subtract 1 from cx, if not zero jump back to again finish: mov ax, 4C00h ; Terminate program int 21h ; correctly end
The above loops from capital A to Z and prints out all charaters.What I'm wondering is could the above loop be used to print out A-Z and its corresponding ASCII value (e.g)
A 65
B 66
C 67
I'm guessing I'll need a unconditional loop,and some sort of comparison check...anyones input as to how I would go about coding this would be very much appreciated.Thanks.
Last edited by brian.p; Jan 27th, 2007 at 6:56 am.
•
•
Join Date: Nov 2006
Posts: 134
Reputation:
Solved Threads: 3
Assembly Syntax (Toggle Plain Text)
string db 4 dup( ' ' ), '$' mov al, 41h ; the character 041h (i.e.'A') mov cx, 26 ; start the counter at 26 in cx again: push ax ;save character mov string[ 0 ], al ;copy character to start of string mov bh, 10 div bh ;MS digit of ascii code into al, LS digit into ah add ax, '00' ;convert digits into ascii codes mov word ptr string[ 2 ], ax ;copy digits into string mov ah, 9 ;print string int 21h pop ax ;retrieve character inc al ;next character loop again ; subtract 1 from cx, if not zero jump back to again finish: mov ax, 4C00h ; Terminate program int 21h ; correctly
•
•
Join Date: Jan 2007
Posts: 9
Reputation:
Solved Threads: 0
•
•
•
•
Assembly Syntax (Toggle Plain Text)
string db 4 dup( ' ' ), '$' mov al, 41h ; the character 041h (i.e.'A') mov cx, 26 ; start the counter at 26 in cx again: push ax ;save character mov string[ 0 ], al ;copy character to start of string mov bh, 10 div bh ;MS digit of ascii code into al, LS digit into ah add ax, '00' ;convert digits into ascii codes mov word ptr string[ 2 ], ax ;copy digits into string mov ah, 9 ;print string int 21h pop ax ;retrieve character inc al ;next character loop again ; subtract 1 from cx, if not zero jump back to again finish: mov ax, 4C00h ; Terminate program int 21h ; correctly
thanks for the help,and sorry for my late reply...
![]() |
Similar Threads
- operator/function for a list of letters (Python)
- Few problems in char and pointers. (C++)
- Array troubles? (C++)
- Sorting Strings (Java)
- Java Programmers wanted. Need Help please (Java)
- buffer (C)
- URGENT: Need help on I/O code! (Java)
- Print initials to standard output in letters. (Java)
Other Threads in the Assembly Forum
- Previous Thread: Turn on a LED for 5 minutes Use PIC16F84A
- Next Thread: MIPS64 assembly language
| Thread Tools | Search this Thread |





