MASM Assembly Language x86 Processor: Packed BCD to ASCII Program. Hello Chegg e
ID: 3596473 • Letter: M
Question
MASM Assembly Language x86 Processor: Packed BCD to ASCII Program.
Hello Chegg experts, this is one of my programming assignments for MASM.
I desperately need your help on this!! Also use Irvine32 library.
Here is the assignment:
Packed_BCD_to_ASCII (Chapter 7, Pr 3)
Write a procedure named PackedToAsc that converts a 4-byte packed decimal number to a string of ASCII decimal digits. Pass the packed number to the procedure in EAX, and pass a pointer to a buffer that will hold the ASCII digits. If EAX receives a packed BCD number like DWORD 87654321h, it should return a string of ASCII digits in a buffer like "87654321" to display. For this, an array is defined as
The output of ASCII buffer will be
Thank you in advance..
numbers DWORD 87654321h, 45346894h, 193492h, 123h, 3hPacked BCD to ASCII (Chapter 7, Pr 3) Write a procedure named PackedTOAsc that converts a 4-byte packed decimal number to a string of ASCIl decimal digits. Pass the packed number to the procedure in EAX, and pass a pointer to a buffer that will hold the ASCII digits. If EAX receives a packed 6CD number like DWORD B7654321h, it shoud retui a slring of ASCIl digits in a bulfer like "87654321" to dsplay. For this, an array is defined as The output of ASCII buffer will be 4534689 00000003
Explanation / Answer
INCLUDE Irvine32.inc
.data
numbers DWORD 87654321h, 45346894h, 193492h, 123h, 3h
buffer BYTE 8 DUP(1), 0 ; 8 digits plus null character
.code
main8stub PROC
mov ecx,LENGTHOF numbers ; Prepare for LOOP
mov esi,OFFSET numbers
L1:
; Prepare pointer to buffer and packed decimal number
mov edx,OFFSET buffer
mov eax,[esi]
; Call _PackedToAsC to convert to ASCII digits
call _PackedToAsC
; Display string of digits
mov edx,OFFSET buffer
call WriteString
call crlf
; Get next number
add esi,4
loop L1
main8stub ENDP
;----------------------------------------------------------------
_PackedToAsc PROC USES ecx esi
;
; procedure that converts a 4-byte packed decimal number
; to a string of ASCII decimal digits
; Receives: EAX, packed decimal number
; EDX, pointer to a buffer with ASCII returned
; Returns: String of ASCII digits in buffer pointed by EDX
;------------------------------------------------------------------
add edx,7
mov ecx,8
L2:
mov ebx,eax
and ebx,0fh
add ebx,30h
mov [edx],bl
dec edx
shr eax,4
loop L2
ret
_PackedToAsc ENDP
END main8stub
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.