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(clExplanation / 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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.