Question

.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?

Était-ce utile?

La solution

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] :(

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top