Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I have to convert this C style pseudocode into Assembly Language (.asm).

ID: 3740450 • Letter: H

Question

Hello, I have to convert this C style pseudocode into Assembly Language (.asm). I was told to use the TEST function in place of CMP and to use the print_char macro for a single character like '1' and '0' which are present in the C pseudocode. I was also told I have to back up the induction variable before the print_char is used and restore the induction variable value after print_char is used. Any induction variables can be used in the assembly program. cl is just a placeholder in the C pseudocode. MSB means "Most SIgnificant Bit"

If anyone can convert this code to Assembly Language and implement the things specified in the initial paragraph, it would be greatly appreciated. Thanks.

cl =?// initialize the induction variable while(cl

Explanation / Answer

Answer:

Assembly Language Code :

main:

push rbp

mov rbp, rsp

sub rsp, 16

mov DWORD PTR [rbp-4], 0

mov DWORD PTR [rbp-8], 0

jmp .L2

.L3:

mov edi, 48

call putchar

sal DWORD PTR [rbp-4]

add DWORD PTR [rbp-8], 1

.L2:

cmp DWORD PTR [rbp-8], 7

jle .L3

mov eax, 0

leave

ret

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote