Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *************Addition
- 1. f1.c
- #include<stdio.h>
- #include<conio.h>
- int a=60,b=70,c;
- extern far int addition(int a,int b);
- void main()
- {
- clrscr();
- c=addition(a,b);
- printf("Addition=%d",c);
- getch();
- }
- 2. f2.asm
- ; _ prefix when in asm variables when external
- extrn _a:word
- extrn _b:word
- public _addition
- code segment
- assume cs:code
- _addition proc far
- mov ax,_a
- add ax,_b
- ret
- _addition endp
- code ends
- end
- ;turbo C only takes from AX
- **********Cel to fah
- 1. f1.c
- #include<stdio.h>
- #include<conio.h>
- int c=60,f;
- extern far int convert(int c);
- void main()
- {
- clrscr();
- f=convert(c);
- printf("f=%d",f);
- getch();
- }
- 2. f2.asm
- extrn _c:word
- public _convert
- code segment
- assume cs:code
- _convert proc far
- mov ax,_c
- mov bx,05
- div bx
- mov bx,09h
- mul bx
- mov bx,032
- add ax,bx
- ret
- _convert endp
- code ends
- end
- ***************LCM
- 1. C
- #include<stdio.h>
- #include<conio.h>
- int a=5,b=10,c;
- extern far int convert(int a,int b);
- void main()
- {
- clrscr();
- c=convert(a,b);
- printf("lcm=%d", c);
- getch();
- }
- 2.
- extrn _a:word
- extrn _b:word
- public _convert
- code segment
- assume cs:code
- _convert proc far
- mov ax,_a
- mov bx,_b
- one: cmp ax,bx
- jc loop1
- loop1: xchg ax,bx
- jmp read
- read: sub ax,bx
- jnz one
- mov ax,bx
- mov ax,_a
- mov cx,_b
- mul cx
- div bx
- ret
- _convert endp
- code ends
- end
- steps:
- 1. tasm f2.asm
- 2. open tc.exe
- 3. options ma case sensitive and output directory to \BIN
- 4. add obj and c to project
- 5. build all and run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement