Write a short assembly language program for the following task. Write a program
ID: 3619183 • Letter: W
Question
Write a short assembly language program for the following task. Write a program to convert the contents of a block of RAM into "ASCII hex" and leave the results in another block of RAM. Upon startup, the starting address of the block to be converted is located at address $8000, the starting address of the result block is located at address $8002 and the number of bytes to convert is located at address $8004 (one byte). Your program should include a subroutine to do the conversion of each nibble into its corresponding ASCII code. Note: in order to convert a byte into ASCII hex, you must separate the 8-bit byte into two 4-bit nibbles and then use. the ASCII chart to convert the nibble into an ASCII characterExplanation / Answer
; i've used the concept of pointers ..tomove to nxt loc increment it mov cx,[8004] ; count mov si,[8000] ;starting addr -data mov di,[8002] ;statring addr -result again: mov ax,[si] ; moves 1st data into acc mov bx,ax ; stores acopy into b-reg and ax,#0fh ; masks upper call sr ; callssubroutine mov [di],ax ; storesresult inc di ; moves to next resultloc mov bx,ax swap ax ; swaps the upper andlower and ax,#0fh call sr mov [di],ax inc di inc si ; moves to nextdata loc loop again ; loop executescount times end ; end of program sr : cmp ax,#0ah jl thr ; jumps thr if it's no add ax,#37h sjmp en thr : add ax,#0ah ; to get the original no add ax,#30h en : ret ; instructions may change depending on the controller orprocessor ; the logic remains the same
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.