Statement: Write an assembly language program to convert the contents of the five memory locations starting from 2000H into an ASCII character. Place the result in another five memory locations starting from 2200H.
Sample Problem
(2000H) = 1
(2001H) = 2
(2002H) = 9
(2003H) = A
(2004H) = B
Result:(2200H) = 31
(2201H) = 32
(2202H) = 39
(2203H) = 41
(2204H) = 42
Source program:
LXI SP, 27FFH : Initialize stack pointer
LXI H, 2000H : Source memory pointer
LXI D, 2200H : Destination memory pointer
MVI C, O5H : Initialize the counter
BACK: MOV A, M : Get the number
CALL ASCII : Call subroutine ASCII
STAX D : Store result
INX H : Increment source memory pointer
INX D : Increment destination memory pointer
DCR C : Decrement count by 1
CJNZ : if not zero, repeat
HLT : Stop program execution subroutine ASCII
ASCII: CPI, OAH : Check if number is OAR
JNC NEXT : If yes go to next otherwise continue
ADI 30H
JMP LAST
NEXT: ADI 37H
LAST: RET : Return to main program
Subroutine:
Subroutine 'ASCII' converts a hexadecimal digit to ASCII.The digit is passed using accumulator and the result is stored in accumulator.Stack starts From 27FEH to 27FDH.
FLOWCHART
google_protectAndRun("render_ads.js::google_render_ad", google_handleError, google_render_ad);
google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad);
google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad);
Note: The ASCII Code (American Standard Code for Information Interchange) is commonly used for communication. In such cases we need to convert binary number to its ASCII equivalent. It is a seven bit code. In this code number 0 through 9 are represented as 30 through 39 respectively and letters A through Z are represented as 41H through 5AH. Therefore, by adding 30H we can convert number into its ASCII equivalent and by adding 37H we can convert letter to its ASCII equivalent.
No comments:
Post a Comment