Advertisement
MichaelPetch

SO stack based vars

May 2nd, 2019
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. ifndef ??version
  2. ?debug macro
  3. endm
  4. $comm macro name,dist,size,count
  5. comm dist name:BYTE:count*size
  6. endm
  7. else
  8. $comm macro name,dist,size,count
  9. comm dist name[size]:BYTE:count
  10. endm
  11. endif
  12. ?debug S "test1194.c"
  13. ?debug C E9B48CA24E0A74657374313139342E63
  14. _TEXT segment byte public 'CODE'
  15. _TEXT ends
  16. DGROUP group _DATA,_BSS
  17. assume cs:_TEXT,ds:DGROUP
  18. _DATA segment word public 'DATA'
  19. d@ label byte
  20. d@w label word
  21. _DATA ends
  22. _BSS segment word public 'BSS'
  23. b@ label byte
  24. b@w label word
  25. _BSS ends
  26. _TEXT segment byte public 'CODE'
  27. ;
  28. ; void test()
  29. ;
  30. assume cs:_TEXT
  31. _test proc near
  32. push bp
  33. mov bp,sp
  34. sub sp,12
  35. ;
  36. ; {
  37. ; int x=100, y=200;
  38. ;
  39. mov word ptr [bp-2],100
  40. mov word ptr [bp-4],200
  41. ;
  42. ; int far *ptx;
  43. ; int far *pty;
  44. ; ptx=&x;
  45. ;
  46. lea ax,word ptr [bp-2]
  47. mov word ptr [bp-6],ss
  48. mov word ptr [bp-8],ax
  49. ;
  50. ; pty=(int *)malloc(sizeof(int));
  51. ;
  52. mov ax,2
  53. push ax
  54. call near ptr _malloc
  55. pop cx
  56. cwd
  57. mov word ptr [bp-10],dx
  58. mov word ptr [bp-12],ax
  59. ;
  60. ; ptx=pty;
  61. ;
  62. mov ax,word ptr [bp-10]
  63. mov dx,word ptr [bp-12]
  64. mov word ptr [bp-6],ax
  65. mov word ptr [bp-8],dx
  66. ;
  67. ; }
  68. ;
  69. mov sp,bp
  70. pop bp
  71. ret
  72. _test endp
  73. ;
  74. ; void test2()
  75. ;
  76. assume cs:_TEXT
  77. _test2 proc near
  78. push bp
  79. mov bp,sp
  80. sub sp,12
  81. ;
  82. ; {
  83. ; int x=100, y=200;
  84. ;
  85. mov word ptr [bp-2],100
  86. mov word ptr [bp-4],200
  87. ;
  88. ; int far *ptx;
  89. ; int far *pty;
  90. ; ptx=&x;
  91. ;
  92. lea ax,word ptr [bp-2]
  93. mov word ptr [bp-6],ss
  94. mov word ptr [bp-8],ax
  95. ;
  96. ; pty=(int *)malloc(sizeof(int));
  97. ;
  98. mov ax,2
  99. push ax
  100. call near ptr _malloc
  101. pop cx
  102. cwd
  103. mov word ptr [bp-10],dx
  104. mov word ptr [bp-12],ax
  105. ;
  106. ; *ptx=*pty;
  107. ;
  108. les bx,dword ptr [bp-12]
  109. mov ax,word ptr es:[bx]
  110. les bx,dword ptr [bp-8]
  111. mov word ptr es:[bx],ax
  112. ;
  113. ; }
  114. ;
  115. mov sp,bp
  116. pop bp
  117. ret
  118. _test2 endp
  119. ;
  120. ; int main()
  121. ;
  122. assume cs:_TEXT
  123. _main proc near
  124. push bp
  125. mov bp,sp
  126. ;
  127. ; {
  128. ; return 0;
  129. ;
  130. xor ax,ax
  131. jmp short @3@58
  132. @3@58:
  133. ;
  134. ; }
  135. ;
  136. pop bp
  137. ret
  138. _main endp
  139. ?debug C E9
  140. _TEXT ends
  141. _DATA segment word public 'DATA'
  142. s@ label byte
  143. _DATA ends
  144. _TEXT segment byte public 'CODE'
  145. _TEXT ends
  146. public _main
  147. public _test2
  148. extrn _malloc:near
  149. public _test
  150. _s@ equ s@
  151. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement