For this quiz you must write an implementation of the functi

For this quiz, you must write an implementation of the function get_bit in ARM assembly language: void set_bit(int *data, int size, int desired, int setto); The function accepts a pointer to an array of integers and the size of the array in words. It sets or clears the desired bit, where desired is an integer bit number. If the value of setto is zero, set the bit to zero. If the value of setto is non-zero (any possible value), set the bit to a one. For example, suppose the function is passed these two values in the array. They are in binary as passed to the function, but I have expressed them as hexadecimal here: c4a16062 Id8ebb48 set_bit(data, 2, 0, 0) will clear the high order bit of the first value, changing it to 44a16062. set_bit(data, 2, 31, 1) will set the low bit of the first value to true, changing the value to 44a16063. set_bit(data, 2, 32, 1) will set the high bit of the second word to true, changing the value to 9d8ebb48. Bits 0-31 are the first word, 32-63 are the second word, and so on. If a value is supplied to desired that is outside the range of possible values, do nothing (certainly, don\'t crash). The program quiz system is persistent, meaning your program will remain in the window below until the assignment closes.

Solution

.file 1 \"\" .section .mdebug.abi32 .previous .gnu_attribute 4, 1 .abicalls .section .text._Z7set_bitPjtb,\"axG\",@progbits,_Z7set_bitPjtb,comdat .align 2 .weak _Z7set_bitPjtb $LFB0 = . .set nomips16 .ent _Z7set_bitPjtb .type _Z7set_bitPjtb, @function _Z7set_bitPjtb: .frame $fp,8,$31 # vars= 0, regs= 1/0, args= 0, gp= 0 .mask 0x40000000,-4 .fmask 0x00000000,0 .set noreorder .set nomacro addiu $sp,$sp,-8 $LCFI0: sw $fp,4($sp) $LCFI1: move $fp,$sp movz $31,$31,$0 $LCFI2: sw $4,8($fp) move $3,$5 move $2,$6 sh $3,12($fp) sb $2,16($fp) lbu $2,16($fp) nop beq $2,$0,$L2 nop lw $2,8($fp) nop lw $3,0($2) lhu $2,12($fp) li $4,1 # 0x1 sll $2,$4,$2 or $3,$3,$2 lw $2,8($fp) nop sw $3,0($2) b $L4 nop $L2: lw $2,8($fp) nop lw $3,0($2) lhu $2,12($fp) li $4,1 # 0x1 sll $2,$4,$2 nor $2,$0,$2 and $3,$3,$2 lw $2,8($fp) nop sw $3,0($2) $L4: move $sp,$fp lw $fp,4($sp) addiu $sp,$sp,8 j $31 nop .set macro .set reorder .end _Z7set_bitPjtb $LFE0: .size _Z7set_bitPjtb, .-_Z7set_bitPjtb .section .text._Z7get_bitjt,\"axG\",@progbits,_Z7get_bitjt,comdat .align 2 .weak _Z7get_bitjt $LFB1 = . .set nomips16 .ent _Z7get_bitjt .type _Z7get_bitjt, @function _Z7get_bitjt: .frame $fp,8,$31 # vars= 0, regs= 1/0, args= 0, gp= 0 .mask 0x40000000,-4 .fmask 0x00000000,0 .set noreorder .set nomacro addiu $sp,$sp,-8 $LCFI3: sw $fp,4($sp) $LCFI4: move $fp,$sp movz $31,$31,$0 $LCFI5: sw $4,8($fp) move $2,$5 sh $2,12($fp) lhu $2,12($fp) lw $3,8($fp) nop srl $2,$3,$2 andi $2,$2,0x1 andi $2,$2,0x00ff move $sp,$fp lw $fp,4($sp) addiu $sp,$sp,8 j $31 nop .set macro .set reorder .end _Z7get_bitjt $LFE1: .size _Z7get_bitjt, .-_Z7get_bitjt .rdata .align 2 $LC0: .ascii \"%d \\000\" .text .align 2 .globl main $LFB2 = . .set nomips16 .ent main .type main, @function main: .frame $fp,40,$31 # vars= 8, regs= 2/0, args= 16, gp= 8 .mask 0xc0000000,-4 .fmask 0x00000000,0 .set noreorder .cpload $25 .set nomacro addiu $sp,$sp,-40 $LCFI6: sw $31,36($sp) $LCFI7: sw $fp,32($sp) movz $31,$31,$0 $LCFI8: move $fp,$sp $LCFI9: .cprestore 16 sw $0,28($fp) sw $0,24($fp) b $L8 nop $L9: lw $2,24($fp) nop andi $2,$2,0xffff addiu $3,$fp,28 move $4,$3 move $5,$2 li $6,1 # 0x1 lw $2,%call16(_Z7set_bitPjtb)($28) nop move $25,$2 jalr $25 nop lw $28,16($fp) lw $2,24($fp) nop addiu $2,$2,2 sw $2,24($fp) $L8: lw $2,24($fp) nop slt $2,$2,8 andi $2,$2,0x00ff bne $2,$0,$L9 nop li $2,7 # 0x7 sw $2,24($fp) b $L10 nop $L11: lw $3,28($fp) lw $2,24($fp) nop andi $2,$2,0xffff move $4,$3 move $5,$2 lw $2,%call16(_Z7get_bitjt)($28) nop move $25,$2 jalr $25 nop lw $28,16($fp) nop lw $3,%got($LC0)($28) nop addiu $4,$3,%lo($LC0) move $5,$2 lw $2,%call16(printf)($28) nop move $25,$2 jalr $25 nop lw $28,16($fp) lw $2,24($fp) nop addiu $2,$2,-1 sw $2,24($fp) $L10: lw $2,24($fp) nop nor $2,$0,$2 srl $2,$2,31 andi $2,$2,0x00ff bne $2,$0,$L11 nop li $4,10 # 0xa lw $2,%call16(putchar)($28) nop move $25,$2 jalr $25 nop lw $28,16($fp) move $2,$0 move $sp,$fp lw $31,36($sp) lw $fp,32($sp) addiu $sp,$sp,40 j $31 nop .set macro .set reorder .end main $LFE2: .size main, .-main .section .eh_frame,\"aw\",@progbits $Lframe1: .4byte $LECIE1-$LSCIE1 $LSCIE1: .4byte 0x0 .byte 0x1 .globl __gxx_personality_v0 .ascii \"zP\\000\" .uleb128 0x1 .sleb128 -4 .byte 0x1f .uleb128 0x5 .byte 0x0 .4byte __gxx_personality_v0 .byte 0xc .uleb128 0x1d .uleb128 0x0 .align 2 $LECIE1: $LSFDE5: .4byte $LEFDE5-$LASFDE5 $LASFDE5: .4byte $LASFDE5-$Lframe1 .4byte $LFB2 .4byte $LFE2-$LFB2 .uleb128 0x0 .byte 0x4 .4byte $LCFI6-$LFB2 .byte 0xe .uleb128 0x28 .byte 0x4 .4byte $LCFI8-$LCFI6 .byte 0x11 .uleb128 0x1e .sleb128 2 .byte 0x11 .uleb128 0x1f .sleb128 1 .byte 0x4 .4byte $LCFI9-$LCFI8 .byte 0xd .uleb128 0x1e .align 2 $LEFDE5: .ident \"GCC: (Debian 4.4.5-8) 4.4.5\"
 For this quiz, you must write an implementation of the function get_bit in ARM assembly language: void set_bit(int *data, int size, int desired, int setto); Th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site