0
.data    
    SUM DW 250h
.text
     push SUM
     call func
     ....
 func:
      mov bp, sp
      mov ax, [bp + 2]
      inc ax
      mov [bp + 2], ax
      .....

When I use the push instruction do I push the reference of SUM, or the value? And does SUM changes after I call func?

Jah
  • 1,019
  • 1
  • 11
  • 25
  • 1
    It seems like ax will have the value that you push in (the address SUM), not sure what you're trying to do after that, but you're incrementing the address and putting it back onto the stack – eventi Jun 05 '12 at 13:56
  • @eventi: this looks like an answer :) – Seki Jun 05 '12 at 15:43
  • @seki I don't think there's enough to answer yet :) – eventi Jun 05 '12 at 16:43

1 Answers1

0

You probably want to dereference the address you pass to the function

.data    
    SUM DW 250h
.text
     push [SUM]
     call func
     ....
 func:
     mov bp, sp
     mov bx, [bp + 2]
     mov ax,[bx]
     inc ax
     mov [bx],ax
     mov [bp + 2], ax
     .....

That seems really roundabout, and I'm sure there's an easier way but I don't have a machine with tasm handy. Extra roundabout since you can't use [ax] :(

eventi
  • 87
  • 6