Logo 
Search:

Assembly Language Forum

Ask Question   UnAnswered
Home » Forum » Assembly Language       RSS Feeds

Print letters in alphabet in pyramid based on user entered letter

  Asked By: Redtag    Date: Jan 25    Category: Assembly Language    Views: 1946
  

Hi, I need to write a program that will print the letters in alphabet in increments one line at a time based on user input. This would be using an assembly language. For example, if a user enter a small letter "a" the output would be:

a
ab
abc
abcd
.
.
.
abcdefg...z

if the user enter a small letter "g" the output would be"

g
gh
ghi
ghij
.
.
.
ghijklmn...z

and so on... any help will be highly appreciated. thanks so much in advance.

p.s.
i have tried, but i just can't figure out. i need help badly. the following is my code but i decided to stop because i really can't figure it out. i've trying for several days now... :\

title print_alphabets

ststack segment para stack 'stack'
dw 200h
ststack ends

cdata segment para 'data'
input_msg db 'Enter a letter to start from: $'
newline db 10, 13, '$'
cdata ends

ccode segment para 'code'
assume cs: ccode, ss: ststack, ds: cdata

main:
mov ax, cdata
mov ds, ax

mov ah, 09h
lea dx, input_msg
int 21h

mov ah, 01h
int 21h

; mov bl, al

step1: ;print new line and input
mov ah, 09h
lea dx, newline
int 21h

mov ah, 02h
mov dl, al
int 21h

; cmp dl, al
; je step4

step2: ;increment output
inc dl

step3: ;print incremented output
mov al, dl

mov ah, 02h
mov dl, dl
int 21h

; cmp dl, dl
; je step1

step4:
mov ah, 02h
mov dl, dl
int 21h

inc dl

mov ah, 02h
mov dl, dl
int 21h

step5:
dec dl

endprog:
mov ah, 4ch
int 21h
ccode ends
end main

Share: 

 

No Answers Found. Be the First, To Post Answer.

 




Tagged: