# Положить значение из регистра в стек / push the contents of the register into stack
.macro push(%reg)
	addi sp,sp,-4 # Уменьшить адрес указателя стека на 4 / reduce stack pointer address by 4
	sw %reg,0(sp) # Загрузить содержимое регистра в стек / Load the contents of the register into stack
.end_macro

# Вытащить значение из стека в регистр / Pull out the contents from stack into register
.macro pop(%reg)
	lw %reg,0(sp) # Загрузить содержимое из стека в регистр / Load contents from stack into register
	addi sp,sp,4 # Увеличить адрес указателя стека на 4 / enlarge stack pointer address by 4
.end_macro

# Положить значения всех регистров в стек / push the contents of all registers into stack
.macro pushall
	push ra # Положить в стек значение регистра ra /  Load the contents of the register ra into stack
	pushAs # Положить значения регистров на букву "a" в стек / push the contents of all registers starting with a letter "a" into stack
	pushSs # Положить значения регистров на букву "s" в стек / push the contents of all registers starting with a letter "s" into stack
	pushTs # Положить значения регистров на букву "t" в стек / push the contents of all registers starting with a letter "t" into stack
.end_macro

# Вытащить значения всех регистров из стека / Pull out the contents from stack into all registers
.macro popall
	popTs # Вытащить значения регистров на букву "t" из стека / Pull out the contents of all registers starting with a letter "t" from stack
	popSs # Вытащить значения регистров на букву "s" из стека / Pull out the contents of all registers starting with a letter "s" from stack
	popAs # Вытащить значения регистров на букву "a" из стека / Pull out the contents of all registers starting with a letter "a" from stack
        pop ra # Вытащить значение из стека в регистр ra / Pull out the contents from stack into register ra
.end_macro

# Положить значения регистров на букву "a" в стек / push the contents of all registers starting with a letter "a" into stack
.macro pushAs
	  addi sp,sp,-32 # Уменьшить адрес указателя стека на 32 / reduce stack pointer address by 32
      sw a0,0(sp) # Загрузить содежимое регистра a0 в стек (смещение 0) / Load contents of the register a0 into stack (offset 0)
      sw a1,4(sp) # Загрузить содежимое регистра a1 в стек (смещение 4) / Load contents of the register a1 into stack (offset 4)
      sw a2,8(sp) # Загрузить содежимое регистра a2 в стек (смещение 8) / Load contents of the register a2 into stack (offset 8)
      sw a3,12(sp) # Загрузить содежимое регистра a3 в стек (смещение 12) / Load contents of the register a3 into stack (offset 12)
      sw a4,16(sp) # Загрузить содежимое регистра a4 в стек (смещение 16) / Load contents of the register a4 into stack (offset 16)
      sw a5,20(sp)  # Загрузить содежимое регистра a5 в стек (смещение 20) / Load contents of the register a5 into stack (offset 20)
      sw a6,24(sp)  # Загрузить содежимое регистра a6 в стек (смещение 24) / Load contents of the register a6 into stack (offset 24)
      sw a7,28(sp) # Загрузить содежимое регистра a7 в стек (смещение 28) / Load contents of the register a7 into stack (offset 28)
.end_macro

# Вытащить значения регистров на букву "a" из стека / Pull out the contents of all registers starting with a letter "a" from stack
.macro popAs
      lw a0,0(sp) # Загрузить значение в регистр a0 из стека (смещение 0) / Load contents of the stack (offset 0) into register a0
      lw a1,4(sp) # Загрузить значение в регистр a1 из стека (смещение 4) / Load contents of the stack (offset 4) into register a1
      lw a2,8(sp) # Загрузить значение в регистр a2 из стека (смещение 8) / Load contents of the stack (offset 8) into register a2
      lw a3,12(sp) # Загрузить значение в регистр a3 из стека (смещение 12) / Load contents of the stack (offset 12) into register a3
      lw a4,16(sp) # Загрузить значение в регистр a4 из стека (смещение 16) / Load contents of the stack (offset 16) into register a4
      lw a5,20(sp) # Загрузить значение в регистр a5 из стека (смещение 20) / Load contents of the stack (offset 20) into register a5
      lw a6,24(sp) # Загрузить значение в регистр a6 из стека (смещение 24) / Load contents of the stack (offset 24) into register a6
      lw a7,28(sp) # Загрузить значение в регистр a7 из стека (смещение 28) / Load contents of the stack (offset 28) into register a7
      addi sp,sp,32 # Увеличить адрес указателя стека на 32 / enlarge stack pointer address by 32
.end_macro

# Положить значения регистров на букву "s" в стек / push the contents of all registers starting with a letter "s" into stack
.macro pushSs
	  addi sp,sp,-48 # Уменьшить адрес указателя стека на 48 / reduce stack pointer address by 48
      sw s0,0(sp) # Загрузить содежимое регистра s0 в стек (смещение 0) / Load contents of the register s0 into stack (offset 0)
      sw s1,4(sp) # Загрузить содежимое регистра s1 в стек (смещение 4) / Load contents of the register s1 into stack (offset 4)
      sw s2,8(sp) # Загрузить содежимое регистра s2 в стек (смещение 8) / Load contents of the register s2 into stack (offset 8)
      sw s3,12(sp) # Загрузить содежимое регистра s3 в стек (смещение 12) / Load contents of the register s3 into stack (offset 12)
      sw s4,16(sp) # Загрузить содежимое регистра s4 в стек (смещение 16) / Load contents of the register s4 into stack (offset 16)
      sw s5,20(sp)   # Загрузить содежимое регистра s5 в стек (смещение 20) / Load contents of the register s5 into stack (offset 20)  
      sw s6,24(sp) # Загрузить содежимое регистра s6 в стек (смещение 24) / Load contents of the register s6 into stack (offset 24)
      sw s7,28(sp) # Загрузить содежимое регистра s7 в стек (смещение 28) / Load contents of the register s7 into stack (offset 28)
      sw s8,32(sp)     #;s0  # Загрузить содежимое регистра s8 в стек (смещение 32) / Load contents of the register s8 into stack (offset 32)
      sw s9,36(sp) # Загрузить содежимое регистра s9 в стек (смещение 36) / Load contents of the register s9 into stack (offset 36)
      sw s10,40(sp)    #;a0 # Загрузить содежимое регистра s10 в стек (смещение 40) / Load contents of the register s10 into stack (offset 40)
      sw s11,44(sp)    # Загрузить содежимое регистра s11 в стек (смещение 44) / Load contents of the register s11 into stack (offset 44)
      
.end_macro

# Вытащить значения регистров на букву "s" из стека / Pull out the contents of all registers starting with a letter "s" from stack
.macro popSs
      lw s0,0(sp) # Загрузить значение в регистр s0 из стека (смещение 0) / Load contents of the stack (offset 0) into register s0
      lw s1,4(sp) # Загрузить значение в регистр s1 из стека (смещение 4) / Load contents of the stack (offset 4) into register s1
      lw s2,8(sp) # Загрузить значение в регистр s2 из стека (смещение 8) / Load contents of the stack (offset 8) into register s2
      lw s3,12(sp) # Загрузить значение в регистр s3 из стека (смещение 12) / Load contents of the stack (offset 12) into register s3
      lw s4,16(sp) # Загрузить значение в регистр s4 из стека (смещение 16) / Load contents of the stack (offset 16) into register s4
      lw s5,20(sp) # Загрузить значение в регистр s5 из стека (смещение 20) / Load contents of the stack (offset 20) into register s5
      lw s6,24(sp) # Загрузить значение в регистр s6 из стека (смещение 24) / Load contents of the stack (offset 24) into register s6
      lw s7,28(sp) # Загрузить значение в регистр s7 из стека (смещение 28) / Load contents of the stack (offset 28) into register s7
      lw s8,32(sp) # Загрузить значение в регистр s8 из стека (смещение 32) / Load contents of the stack (offset 32) into register s8
      lw s9,36(sp) # Загрузить значение в регистр s9 из стека (смещение 36) / Load contents of the stack (offset 36) into register s9
      lw s10,40(sp) # Загрузить значение в регистр s10 из стека (смещение 40) / Load contents of the stack (offset 40) into register s10
      lw s11,44(sp) # Загрузить значение в регистр s11 из стека (смещение 44) / Load contents of the stack (offset 44) into register s11
      addi sp,sp,48 # Увеличить адрес указателя стека на 48 / enlarge stack pointer address by 48

.end_macro

# Положить значения регистров на букву "t" в стек / push the contents of all registers starting with a letter "t" into stack
.macro pushTs
	  addi sp,sp,-28 # Уменьшить адрес указателя стека на 28 / reduce stack pointer address by 28
      sw t0,0(sp)# Загрузить содежимое регистра t0 в стек (смещение 0) / Load contents of the register t0 into stack (offset 0)
      sw t1,4(sp) # Загрузить содежимое регистра t1 в стек (смещение 4) / Load contents of the register t1 into stack (offset 4)
      sw t2,8(sp) # Загрузить содежимое регистра t2 в стек (смещение 8) / Load contents of the register t2 into stack (offset 8)
      sw t3,12(sp) # Загрузить содежимое регистра t3 в стек (смещение 12) / Load contents of the register t3 into stack (offset 12)
      sw t4,16(sp) # Загрузить содежимое регистра t4 в стек (смещение 16) / Load contents of the register t4 into stack (offset 16)
      sw t5,20(sp)    # Загрузить содежимое регистра t5 в стек (смещение 20) / Load contents of the register t5 into stack (offset 20)  
      sw t6,24(sp) # Загрузить содежимое регистра t6 в стек (смещение 24) / Load contents of the register t6 into stack (offset 24)

.end_macro

# Вытащить значения регистров на букву "t" из стека / Pull out the contents of all registers starting with a letter "t" from stack
.macro popTs
      lw t0,0(sp)# Загрузить значение в регистр t0 из стека (смещение 0) / Load contents of the stack (offset 0) into register t0
      lw t1,4(sp) # Загрузить значение в регистр t1 из стека (смещение 4) / Load contents of the stack (offset 4) into register t1
      lw t2,8(sp) # Загрузить значение в регистр t2 из стека (смещение 8) / Load contents of the stack (offset 8) into register t2
      lw t3,12(sp) # Загрузить значение в регистр t3 из стека (смещение 12) / Load contents of the stack (offset 12) into register t3
      lw t4,16(sp) # Загрузить значение в регистр t4 из стека (смещение 16) / Load contents of the stack (offset 16) into register t4
      lw t5,20(sp) # Загрузить значение в регистр t5 из стека (смещение 20) / Load contents of the stack (offset 20) into register t5
      lw t6,24(sp) # Загрузить значение в регистр t6 из стека (смещение 24) / Load contents of the stack (offset 24) into register t6
      addi sp,sp,28 # Увеличить адрес указателя стека на 28 / enlarge stack pointer address by 28
.end_macro
