c program convert to tasm

Reply

Join Date: Feb 2007
Posts: 1
Reputation: faith07 is an unknown quantity at this point 
Solved Threads: 0
faith07 faith07 is offline Offline
Newbie Poster

c program convert to tasm

 
0
  #1
Feb 8th, 2007
Hello everyone, Im new in assembly language. I would like to ask your help to teach me how to convert the below C language into tasm language. thank you very much.

#include <stdio.h>
#include <dos.h>
main()
{
unsigned int year;
unsigned char month;
unsigned char day;
union REGS regin,regout;

clrscr();
regin.h.ah=0x2A;
/* intdos(&regin,&regout);*/ int86(0x21,&regin,&regout);
day=regout.h.dh;
year=regout.x.cx;
printf("Today's date is: %d-%d-%d\n",month,day,year);
return(0);
}
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 49
Reputation: Purple Avenger is an unknown quantity at this point 
Solved Threads: 0
Purple Avenger Purple Avenger is offline Offline
Light Poster

Re: c program convert to tasm

 
0
  #2
Feb 9th, 2007
I'd write an assembler program that just printed out "Hello World" first. In doing that, you'll find you've built 70% of what that date printer does.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 31
Reputation: mytime19 is an unknown quantity at this point 
Solved Threads: 1
mytime19 mytime19 is offline Offline
Light Poster

Re: c program convert to tasm

 
0
  #3
Mar 3rd, 2007
well i think you can't use much C lang stuff with tasm.. the reason is that it uses DOS and you know that it can only program 16 bit stuff not 32-bit.. so i got the same problem but just upgraded to masm.. there's inbuilt libraries available in that. or you can work with nasm/fasm.. try any.. have a nice day! good luck
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 129
Reputation: Evenbit is on a distinguished road 
Solved Threads: 4
Evenbit's Avatar
Evenbit Evenbit is offline Offline
Junior Poster

Re: c program convert to tasm

 
0
  #4
Mar 4th, 2007
Originally Posted by mytime19 View Post
well i think you can't use much C lang stuff with tasm.. the reason is that it uses DOS and you know that it can only program 16 bit stuff not 32-bit.. so i got the same problem but just upgraded to masm.. there's inbuilt libraries available in that. or you can work with nasm/fasm.. try any.. have a nice day! good luck
Nonsense! First, there are C compilers available for DOS. Second, TASM does support 32-bit code.

Nathan.
while (CPU is present) {some assembly required}
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 129
Reputation: Evenbit is on a distinguished road 
Solved Threads: 4
Evenbit's Avatar
Evenbit Evenbit is offline Offline
Junior Poster

Re: c program convert to tasm

 
0
  #5
Mar 4th, 2007
Originally Posted by faith07 View Post
Hello everyone, Im new in assembly language. I would like to ask your help to teach me how to convert the below C language into tasm language. thank you very much.

#include <stdio.h>
#include <dos.h>
main()
{
unsigned int year;
unsigned char month;
unsigned char day;
union REGS regin,regout;

clrscr();
regin.h.ah=0x2A;
/* intdos(&regin,&regout);*/ int86(0x21,&regin,&regout);
day=regout.h.dh;
year=regout.x.cx;
printf("Today's date is: %d-%d-%d\n",month,day,year);
return(0);
}
Simple:

mov ah, 0x2A
int 0x21

You should find the 'day' in DH and the 'year' in CX.

Nathan.
while (CPU is present) {some assembly required}
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 8
Reputation: Garni is an unknown quantity at this point 
Solved Threads: 1
Garni Garni is offline Offline
Newbie Poster

Re: c program convert to tasm

 
0
  #6
Apr 17th, 2007
Originally Posted by faith07 View Post
Hello everyone, Im new in assembly language. I would like to ask your help to teach me how to convert the below C language into tasm language. thank you very much.

#include <stdio.h>
#include <dos.h>
main()
{
unsigned int year;
unsigned char month;
unsigned char day;
union REGS regin,regout;

clrscr();
regin.h.ah=0x2A;
/* intdos(&regin,&regout);*/ int86(0x21,&regin,&regout);
day=regout.h.dh;
year=regout.x.cx;
printf("Today's date is: %d-%d-%d\n",month,day,year);
return(0);
}


for this regarding DOS interrupt int21h u can refer any DOS or BIOS interrupt manuals, that clearly will explain u what are all the register that got affected after an interrupt in invoked. For printing the final result on the display you need to first of all convert the packed decimal value returned in any general purpose register in to proper string, just by dividing the entire decimal value by 10 and extracting the remainder to find out the character. Later u can use some other DOS int services or BIOS Display related services (int 10h) to display the actual character in the screen positioned.
-------------------------------
here is how it will look like.
-------------------------------
under data section you need to define the below mentioned things.
________________________________________________________
year dw 0
month db 0
day db 0

________________________________________________________
clrscr();
// Garni - for clearing the screen u can use any of the display set mode BIOS services.

regin.h.ah=0x2A;

// Garni - mov ah,2ah

/* intdos(&regin,&regout);*/ int86(0x21,&regin,&regout);

// Garni - int 21h

day=regout.h.dh;
// Garni - mov day,dh

year=regout.x.cx;
// Garni - mov year,cx

printf("Today's date is: %d-%d-%d\n",month,day,year);

// Garni - take care of printing the value as explained above.

return(0);

// Garni - for terminating the exe and for telling DOS the exe statsu we have another DOS service, refer to DOS and BIOS interrupt service manuals.
Last edited by Garni; Apr 17th, 2007 at 9:50 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 1
Reputation: dr.m is an unknown quantity at this point 
Solved Threads: 0
dr.m dr.m is offline Offline
Newbie Poster

Re: c program convert to tasm

 
0
  #7
Aug 1st, 2007
Do we have a program which can convert C or C++ to assembly ?
Please give me a link for help me
Tanks a lot
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 129
Reputation: Evenbit is on a distinguished road 
Solved Threads: 4
Evenbit's Avatar
Evenbit Evenbit is offline Offline
Junior Poster

Re: c program convert to tasm

 
0
  #8
Aug 1st, 2007
Originally Posted by dr.m View Post
Do we have a program which can convert C or C++ to assembly ?
Please give me a link for help me
Tanks a lot
Yes, these programs are called compilers. You can find a nice list of C and/or C++ compilers here:
http://www.thefreecountry.com/compilers/cpp.shtml

Study the command-line options... most have a switch or two to allow you to specify the assembly language output.
while (CPU is present) {some assembly required}
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC