Advertisement
apl-mhd

stack pointer

Sep 27th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 100h
  2.  
  3.  
  4. .stack 100h
  5. .DATA
  6. W dw 1,2,3,4,5,6,7,8  
  7.  
  8. .CODE
  9.                  
  10.                  
  11.                
  12.     mov cx,8
  13.     mov dx,0
  14.     mov si,0
  15.    
  16.    push cx
  17.    
  18.     copy_:    
  19.     push W[SI]
  20.     add si,2  
  21.     LOOP copy_
  22.  
  23.   mov ax,1
  24.   ;mov cx,8
  25.   pop cx
  26.   push cx
  27.   mov si,0
  28.    
  29.   reverse:
  30.   pop W[si]
  31.   add si,2
  32.   Loop reverse
  33.  
  34.  
  35.       mov si,0
  36.       ;mov cx,8
  37.       pop cx
  38.       mov bx, 0  
  39.    
  40.    
  41.    CALCULATION_:
  42.       sub cx,1
  43.     cmp cx, 4
  44.     jge SUM
  45.    
  46.     jmp multi
  47.     hlt
  48.    
  49.    
  50.     ;JE MULTI_
  51.     ;MULTI_:  
  52.     ;LOOP CALCULATION_
  53.    
  54.    
  55.      
  56.     SUM:
  57.     add bx, w[si]
  58.     add si,2
  59.     jmp CALCULATION_
  60.     hlt
  61.          
  62.     multi:
  63.    
  64.     imul  w[si]
  65.     add si,2
  66.      
  67.     cmp cx,0
  68.     jz dead
  69.     jmp CALCULATION_
  70.    
  71.     dead:  
  72.    
  73.    
  74.     mov cx, ax ;mov multiplication
  75.     mov ax, bx ;mov sum tom ax
  76.     mov bx, cx ; move multiplication to bx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement