Stack Data Structure: Simple Calculator
Implement the macros pushq, popq and plus such that the following assembly code can be used as a simple calculator:
.equ ZERO, 0 .equ RIP, 1 .equ RSP, 3 .equ TMP1, 7 .equ TMP2, 8 .macro stack_init orq %ZERO, %ZERO, %RSP .endm .macro pushq REG # your code here .endm .macro popq REG # your code here .endm .macro set VAL, REG orq \VAL, %ZERO, \REG .endm .macro enter VAL set \VAL, %TMP1 pushq %TMP1 .endm .macro plus # your code here .endm .macro mult # your code here .endm .text stack_init enter $1 enter $2 enter $3 plus mult