Advertisement
nguyenvanquan7826

A2_BC_D pascal with asm

Oct 8th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.85 KB | None | 0 0
  1. Tính A^2-B(C-D). Nhập xuất bằng pascal, tính toàn bằng ASM.
  2.  
  3. File A2_BC_D.pas.
  4.  
  5. program bai1;
  6. var a, b, c, d: integer;
  7. {$F+}
  8.      function CAL:integer; external;
  9.      {$L C:\TASM\CALPROC.OBJ}
  10. {$F-}
  11.  
  12.  
  13. BEGIN
  14.      write('a = '); readln(a);
  15.      write('b = '); readln(b);
  16.      write('c = '); readln(c);
  17.      write('d = '); readln(d);
  18.      writeln('a^2 - b(c - d) = ', CAL);
  19.      readln;
  20. END.
  21.  
  22. File CALPROC.asm nằm trong C:\TASM\
  23.  
  24. .model large
  25. .data
  26.     EXTRN a: word, b: word, c: word, d: word
  27.  
  28.    
  29. .code
  30.     public CAL
  31.     CAL proc      
  32.              
  33.         mov ax, a
  34.         mul ax          ; ax = ax*ax  
  35.         push ax
  36.        
  37.         mov cx, c
  38.         mov dx, d
  39.         sub cx, dx      ; cx = cx - dx
  40.        
  41.         mov ax, b       ; ax = b
  42.         mul cx          ; ax = ax * cx = bx*(cx-dx)
  43.         mov bx, ax      ; bx = ax
  44.         pop ax          ; ax = ax^2
  45.         sub ax, bx      ; ax = ax^2-bx(cx-dx)
  46.        
  47.         ret
  48.     CAL endp
  49. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement