![]() |
| ||
| addcc instruction i am in school taking a machine language class and need helpt writing out the asm code for teh addcc instruction. i have a detailed source code complete taht just needs teh blanks to be filled in. .global main main: save %sp, -96, %sp ! %l1, %l2 will be set in gdb set_vars: ! set %l1, %l2 NOW clr %l7 ! init the CC holder to 0 ! Here is where you need to start the add loop ! Add %l1 + %l2 = %l0 ! See page 116 for the C algorithm for addition ! Store result in %l0 !-------------------------------------------------------------------------- setccs: !at this point, we know that %l0 holds the result of our addition. !we also know that %l1 holds our first operand !and that %l2 holds our second operand ! %l7 will hold cc's (it is set to 0 right now) zero: !found at bottom of register (0x1) - !You can use tst for the zero orcc %l0, %g0, %g0 bne zero_nset nop zero_set: !0 is the result mov 1, %l7 ba zero_set_out ! get out if %l0 is 0 nop zero_nset: !-------------------------------------------------------------------------- negative: !found at second bit of register (0x2) - !Use N = result<31> = 1; N=1 else N=0 srl %o0, 31, %o0 !shift 31 times to get the sign bit sll %o0, 1, %o0 !shift it over 1 place or %o0, %l7, %l7 !place it in my CC register neg_set: !-------------------------------------------------------------------------- carry: !found at third bit of register (0x4) !if %l1 + %l2 = %l0 ! Check the order of operations !Use C = %l1<31> & %l2<31> | %l1<31> & !%l0<31> | %l2<31> & !%l0<31> ! CC is set in the lsb of %o0 sll %o0, 2, %o0 !shift it over 2 places or %o0, %l7, %l7 !place it in my CC register carry_set: !-------------------------------------------------------------------------- overflow: !found at forth bit of register (0x8) ! Check the order of operations !Use V = !%l1<31> & !%l2<31> & %l0<31> | %l1<31> & %l2<31> & !%l0<31> ! CC is set in the lsb of %o0 sll %o0, 3, %o0 !shift it over 3 places or %o0, %l7, %l7 !place it in my CC register overflow_set: !-------------------------------------------------------------------------- ! End of condition code setting zero_set_out: ! As discussed, if we have 0, the rest is pointless to do dunn: ! Here is where you need to print out %l1, %l2, %l0 and %l7 ret restore |
| All times are GMT -4. The time now is 9:11 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC