Alex Larose

Generation

testsFri, 17 Mar 2023

.section .data output_string: .space 10 # allocate space for the output string .section .text .globl printbin printbin: pushl %ebp # set up the stack frame movl %esp, %ebp movl 8(%ebp), %eax # get the input character from the C program movl output_string, %ecx # set up a pointer to the output string # call donibble to process the high nibble movb %al, %ah shr $4, %ah call donibble # add a space character between the nibbles movb $0x20, (%ecx) incl %ecx # call donibble to process the low nibble movb %al, %ah and $0x0f, %ah call donibble movl output_string, %eax # return a pointer to the output string popl %ebp # restore the stack frame ret donibble: pushl %ebp # set up the stack frame movl %esp, %ebp movl 8(%ebp), %eax # get the input nibble and $0x0f, %al # mask off the high bits # convert the nibble to an ASCII character and store it in the output string add $0x30, %al movb %al, (%ecx) incl %ecx popl %ebp # restore the stack frame ret

## Source Code:

Questions about programming?Chat with your personal AI assistant