# integer arithmetic demo addi x5,x0,7 # x5 = 7 addi x6,x0,6 # x6 = 6 add x7,x5,x6 # x7 = 7+6 sub x8,x5,x6 # x8 = 7-6 addi x9,x0,-6 # show number # how to create a two complement number addi x10,x0,11 # x10 = 11 addi x11,x0,-1 # x11 is all binary one xor x12,x10,x11 # inverse all bits in x10 # now x12 is one complement number addi x12,x12,1 # + 1, and x12 becomes -11 add x13,x5,x9 # x13 = 7+(-6) # floating point demo # first create a single precision -5 in x6 lui x6,0x0C0A00 # x6 = fconst(-5) sw x6,16(x0) # put it to M[16] flw f2,16(x0) # f2 = -5 fadd.s f3,f2,f2 # f3 = (-5)+(-5)