Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Tính A^2-B(C-D). Nhập xuất bằng pascal, tính toàn bằng ASM.
- File A2_BC_D.pas.
- program bai1;
- var a, b, c, d: integer;
- {$F+}
- function CAL:integer; external;
- {$L C:\TASM\CALPROC.OBJ}
- {$F-}
- BEGIN
- write('a = '); readln(a);
- write('b = '); readln(b);
- write('c = '); readln(c);
- write('d = '); readln(d);
- writeln('a^2 - b(c - d) = ', CAL);
- readln;
- END.
- File CALPROC.asm nằm trong C:\TASM\
- .model large
- .data
- EXTRN a: word, b: word, c: word, d: word
- .code
- public CAL
- CAL proc
- mov ax, a
- mul ax ; ax = ax*ax
- push ax
- mov cx, c
- mov dx, d
- sub cx, dx ; cx = cx - dx
- mov ax, b ; ax = b
- mul cx ; ax = ax * cx = bx*(cx-dx)
- mov bx, ax ; bx = ax
- pop ax ; ax = ax^2
- sub ax, bx ; ax = ax^2-bx(cx-dx)
- ret
- CAL endp
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement