Advertisement
Guest User

Untitled

a guest
Oct 13th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org  100h
  2.  
  3. jmp main
  4.    
  5.     toSwap1     db 'a'
  6.     toSwap2     db 'b'
  7.     result      dw ?
  8.     numToNeg    dw -9
  9.     string      db  'm', 'a', 'g', 's', 'h', 'i', 'm', 'i', 'm', 'v', 'e', 'n', 'e', 'h', 'e', 'n', 'i', 'm' ,0Dh,0Ah,'$'
  10.     array       db "0000", 0Dh,0Ah, 24h ; line feed   return   and  stop symbol 24h=$ (ASCII).  
  11.     num1        dw 0xAC45
  12.  
  13.  
  14. main: ;using stdcall convention  
  15. jmp next
  16.     push numToNeg
  17.     call _negate@2
  18.     PRINTN " ~ Negate ~ "
  19.     call print_num
  20.     PRINTN
  21.     jmp endn
  22.    
  23.     next:
  24.     mov al,toSwap1
  25.     call print_al_chr
  26.     mov al,toSwap2
  27.     call print_al_chr  
  28.     push offset toSwap2 ;b
  29.     push offset toSwap1 ;a
  30.     call _swap@4
  31.     mov al,toSwap1
  32.     call print_al_chr
  33.     mov al,toSwap2
  34.     call print_al_chr
  35.    
  36.    
  37.    
  38.    
  39.    
  40.  
  41.  
  42.  
  43.  
  44. endn:
  45. mov ah,0
  46. int 16h
  47. ret
  48.  
  49.  
  50. ; ~ Negate ~
  51. ; Input - parameter
  52. ; Output - through ax register. (2 byte signed integer)
  53. ; Function negates the number by 2 completion method.
  54. _negate@2 proc
  55.     push bp
  56.     mov bp,sp
  57.     mov ax,[bp+4]
  58.     not ax
  59.     inc ax
  60.     mov sp,bp
  61.     pop bp
  62. retn 2
  63. _negate@2 endp
  64.  
  65.  
  66. ; ~ Swap ~
  67. ; Input : (char *a, char *b)
  68. ; Output : None
  69. ; Functions swaps between the values of the two pointers.
  70. _swap@4 proc
  71.    
  72.     ;num equ 'b'
  73.      push ax
  74.      push bx
  75.      push bp
  76.      mov bp,sp
  77.      
  78.      mov bx,[bp+8] ;char *a
  79.      mov al, byte ptr [bx]; 'a'
  80.      mov bx, [bp+10] ;char *b
  81.      mov ah, byte ptr [bx]; 'b'
  82.      mov [bx],al
  83.      mov bx, [bp+8]
  84.      mov [bx],ah
  85.      
  86.      mov sp,bp
  87.      pop bp
  88.      pop bx
  89.      pop ax
  90.    
  91.      
  92. retn 4
  93. _swap@4 endp
  94.    
  95.  
  96.  
  97.  
  98.  
  99. include magshimim.inc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement