Advertisement
MichaelPetch

SO global vars

May 2nd, 2019
400
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 "test1195.c"
  13. ?debug C E9A98CA24E0A74657374313139352E63
  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. _DATA segment word public 'DATA'
  27. _x label word
  28. db 100
  29. db 0
  30. _y label word
  31. db 200
  32. db 0
  33. _DATA ends
  34. _TEXT segment byte public 'CODE'
  35. ;
  36. ; void test()
  37. ;
  38. assume cs:_TEXT
  39. _test proc near
  40. push bp
  41. mov bp,sp
  42. ;
  43. ; {
  44. ; ptx=&x;
  45. ;
  46. mov word ptr DGROUP:_ptx+2,ds
  47. mov word ptr DGROUP:_ptx,offset DGROUP:_x
  48. ;
  49. ; pty=(int *)malloc(sizeof(int));
  50. ;
  51. mov ax,2
  52. push ax
  53. call near ptr _malloc
  54. pop cx
  55. cwd
  56. mov word ptr DGROUP:_pty+2,dx
  57. mov word ptr DGROUP:_pty,ax
  58. ;
  59. ; ptx=pty;
  60. ;
  61. mov ax,word ptr DGROUP:_pty+2
  62. mov dx,word ptr DGROUP:_pty
  63. mov word ptr DGROUP:_ptx+2,ax
  64. mov word ptr DGROUP:_ptx,dx
  65. ;
  66. ; }
  67. ;
  68. pop bp
  69. ret
  70. _test endp
  71. ;
  72. ; void test2()
  73. ;
  74. assume cs:_TEXT
  75. _test2 proc near
  76. push bp
  77. mov bp,sp
  78. ;
  79. ; {
  80. ; ptx=&x;
  81. ;
  82. mov word ptr DGROUP:_ptx+2,ds
  83. mov word ptr DGROUP:_ptx,offset DGROUP:_x
  84. ;
  85. ; pty=(int *)malloc(sizeof(int));
  86. ;
  87. mov ax,2
  88. push ax
  89. call near ptr _malloc
  90. pop cx
  91. cwd
  92. mov word ptr DGROUP:_pty+2,dx
  93. mov word ptr DGROUP:_pty,ax
  94. ;
  95. ; *ptx=*pty;
  96. ;
  97. les bx,dword ptr DGROUP:_pty
  98. mov ax,word ptr es:[bx]
  99. les bx,dword ptr DGROUP:_ptx
  100. mov word ptr es:[bx],ax
  101. ;
  102. ; }
  103. ;
  104. pop bp
  105. ret
  106. _test2 endp
  107. ;
  108. ; int main()
  109. ;
  110. assume cs:_TEXT
  111. _main proc near
  112. push bp
  113. mov bp,sp
  114. ;
  115. ; {
  116. ; return 0;
  117. ;
  118. xor ax,ax
  119. jmp short @3@58
  120. @3@58:
  121. ;
  122. ; }
  123. ;
  124. pop bp
  125. ret
  126. _main endp
  127. _TEXT ends
  128. _BSS segment word public 'BSS'
  129. _pty label dword
  130. db 4 dup (?)
  131. _ptx label dword
  132. db 4 dup (?)
  133. ?debug C E9
  134. _BSS ends
  135. _DATA segment word public 'DATA'
  136. s@ label byte
  137. _DATA ends
  138. _TEXT segment byte public 'CODE'
  139. _TEXT ends
  140. public _main
  141. public _test2
  142. extrn _malloc:near
  143. public _test
  144. public _pty
  145. public _ptx
  146. public _y
  147. public _x
  148. _s@ equ s@
  149. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement