source code conversion

Discussion in 'Programmer's Corner' started by hami007, Jan 15, 2009.

  1. hami007

    Thread Starter Member

    Oct 26, 2008
    14
    0
    hello i need to convert the borland c program in assembly language (tasm) this program is for interfacing lcd 16*2 module with computer parallel ports thx
    /* LCD Module Software */
    /* 17th May 1997 */
    /* Copyright 1997 Craig Peacock */
    /* WWW - http://www.senet.com.au/~cpeacock */
    /* Email - cpeacock@senet.com.au */
    /* */
    /* Register Select must be connected to Select Printer (PIN 17) */
    /* Enable must be connected to Strobe (PIN1) */
    /* DATA 0:7 Connected to DATA 0:7 */

    #include <dos.h>
    #include <string.h>

    #define PORTADDRESS 0x378 /* Enter Your Port Address Here */

    #define DATA PORTADDRESS+0
    #define STATUS PORTADDRESS+1
    #define CONTROL PORTADDRESS+2

    void main(void)
    {
    char string[] = {"Testing 1,2,3 "
    "It' Works ! "};
    char init[10];
    int count;
    int len;
    init[0] = 0x0F; /* Init Display */
    init[1] = 0x01; /* Clear Display */
    init[2] = 0x38; /* Dual Line / 8 Bits */

    outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port - Make sure Forward Direction */

    outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer (Register Select) */

    for (count = 0; count <= 2; count++)
    {
    outportb(DATA, init[count]);
    outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
    delay(20); /* Larger Delay for INIT */
    outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe (Enable)*/
    delay(20); /* Larger Delay for INIT */
    }

    outportb(CONTROL, inportb(CONTROL) & 0xF7); /* Reset Select Printer (Register Select) */

    len = strlen(string);

    for (count = 0; count < len; count++)
    {
    outportb(DATA, string[count]);
    outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
    delay(2);
    outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
    delay(2);
    }
    }
     
  2. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    "i need to convert the borland c program in assembly language (tasm)"

    Why?
    I think BC has a command-line version (Turbo-C did). If so, run it in a DOS box, and type in BC (or whatever the command name is) followed by " -?" (no quotes). THis should show you how to call the program to get assembler output.'

    Also. it helps if you wrap the code with {code} & {/code} markers. Replace the "{" and "}" with "[" & "]".

    for (count = 0; count < len; count++)
    {
    outportb(DATA, string[count]);
    outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
    delay(2);
    outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
    delay(2);
    }


    will become

    Code ( (Unknown Language)):
    1. for (count = 0; count < len; count++)
    2. {
    3.     outportb(DATA, string[count]);
    4.     outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
    5.     delay(2);
    6.     outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
    7.     delay(2);
    8. }
    --Rich
     
Loading...