Thaiio.com

Thaiio is the best of PC interfacing Electronic Hardware and Devices resource.

Today , 2007
May 5th, 2008

Programming in Assembly to control IO Printer Port Part 2

    In the part 2, we will learn about controlling program Printer Port and Card 8255 I/O Port by Assembly that can be changed to be language of computer by using Assembler program like SXA-51, Cross-16, Cross-32 that can program by Editor, and then keep in file name .ASM. When comply have finished, will get file .Hex. If we use micro controller like 8051, 8052, 8055, etc. We can take file .Hex to put at CPU by EMULATOR PROGRAM CPU, but I will recommend to use Debug in your PC by typing Debug at C:\> on Dos in order to be learning to use mnemonic code that consist of the main 3 parts like the followings,

1.      Operation Code consists of 2-4 alphabets such as MOV, SJMP, etc.

2.      Operand is operated; it will be the set of alphabets that notify operation that will be one set or 2 sets. If there will be 2, it will have comma (,) like A, #20H, etc.

3.      Comment is explanation the meaning of codes that will be preceded by semicolon (;).

The group of commands of mnemonic code, are divided into 4 main groups,

1.      Logic, such as AND,OR,XOR,NOT

2.      Mathematic  such as INC,DEC,ADD,SUBB,MUL,DIV

3.      Control to manage working

4.      Processing as Boolean

 

The table of writing command doing with data

How to do with data

Examples

1. Directly do at memory position
2. Indirectly do at register position
3. Directly give value with memory
4. According to value of Register
5. According to arrangement
6. Do according condition

MOV A,8CH
MOV A,@R1
MOV A,#7FH
MOV A,R7
MOVC A,@A+PC
INC DPTR

 

The table of the basic command of Assembly

Commands

Examples

Meanings

MOV

MOV A,R1
MOV A,14H
MOV A,#7FH
MOV P1,A

Using for transferring data from start to terminal.
there will be P1 is using to send value out at
Output leg of microcontroller such as 8051,Z80

ADD

ADD A,R1
ADD
A,14H
ADD P1,A

Using for adding data that will have A on the left, if Add R1, A <—- X wrong.  

ANL

ANL A,R1

Is to And value, then keep at the terminal.
<– This is doing And value in A with R1, then keeps value in A as usual.

CJNE

CJNE A,#02H,OUT
MOV P1,#01H
END

Is to do comparison, if the value isn’t be equal, it will skip working <– such as value A isn’t be equal with 02, it will skip at the line named OUT, if to be equal, will take value at P1.

OUT

OUT DX,AL

For sending to PC Port

CLR

CLR A

For clearing data as zero
<– A=0

INC

INC R1

Increasing value> R1=R1+1

DEC

DEC R1

Decreasing value > R1=R1-1

JNZ

ADD P1,A

Skipping to other Label, if A(Accumulator) isn’t be zero

ROR

ROR AL,1

Moving data bit to the right, 1 bit 1 time 1=0001—>1000

ROL

ROL AL,1

Moving data bit to the left, 1 bit 1 time 1=0001—>0010

LOOP

LOOP 0123

For looping working at Address 0123

INT20

INT 20

Show output on screen.

INT21

INT 21

Getting value from keyboard.


Programming to control Card I/O 8255 port in Debug

1. Type the word, Debug at C:\ then will get on the below line.
      2. then, type a, that will get data.
      3. Type
Code like this,

   

4. Press Enter 1 time, then type P or R, you will get for running program that continuously Enter, it will have result like this,

 

     

      From the method I mentioned is experiment to easily program, but writing for real using, you have to write Editor so that you can keep and edit in the next time.

May 5th, 2008

Programming in Assembly to control IO Printer Port

From the article of Assembly, I introduced controlling port of Card I/O 8255 that is card that extends parallel port. Many people might not try to do because there is no card. This article is another method that uses controlling I/O through Printer port getting and sending signal.

The command used to control I/O Printer Data Port
send signal out Printer Port, we use the form of command like this,

OUT Address data port, Value
Address data port of
printer=0378
Value that will send to
printer data port, the number that control 8 bit is 00-FF.

OUT DX,AL

Read the rest of this entry »

May 4th, 2008

Programming in Pascal to connect Parallel Port

Pascal is the another language that can program to connect controlling out of computer‘s port, such as Serial Port, RS-232, Parallel Port, Printer Port. Generally, many languages will have function for sending value and reading value from port.

Although, there is no language, it can be programmed to directly connect along port. So, you have to use the function from DLL file for sending the function that send and read value from port of Pascal like the following, Read the rest of this entry »

May 4th, 2008

Programming in Visual C++ to connect through IO Serial Port Part#2

From programming in visual c++ to connect through i/o serial port #1 for send and receive data with serial port , In this section ,We will learn controllering program communication with serial port by programming in vc++ 6 to create simple program using basic in the part 1 .

1. New project Microsoft VC++ 6 Read the rest of this entry »

May 4th, 2008

Programming in Visual C++ to connect through IO Serial Port1

The context is the fundamental of programming principle by MS Visual C++ 6 connecting through Serial Port of the computer in sending and getting alphabet. For the form of how to programming that will not have ready-made control that will be used like Visual Basic. In this section, you have to use programming principle as reading and writing data file. Anyhow, the data that will be got and sent out to port is like reading and writing data on file. I prepare the step for understanding in programming like this,

4 steps for connecting Serial Port

1. Set variable for keeping file names, data read (Buffer),file handles, value of getting and sending data.

HANDLE hComm; // handle for COM port
DCB dcb;
// data structure that keep value for connecting serial port
char * chCommPort = “COM1″; // we use com port 1
int valReturn; // keep returning value back in some function.
char chBuffer; // keep alphabet in getting and sending data.
unsigned long nReadPort; //keep returning value back in function, ReadFile
unsigned long nWrittenPort; // keep returning value back in function, WriteFile Read the rest of this entry »

May 3rd, 2008

Using Borland C++ Builder to program connection with IO Parallel Port

The fellow programmer that program to connect with computer’s port on Window by using Borland C++ Builder that use the method that I suggested in programming connect to port that is run on DOS. Also, present how to program by MS VC++ 6 for running on Window that is using function of dos.h file, but cannot be used, despite declare #include at the top of program.

First of all, I want to disclaim that I don’t use Borland C++ Builder in programming because I practice just MS VC++ 6 , but trying to search information in the internet , then I find the answer that we have to use in writing function to connect to I/O Port by helping of assembly. I reminded that I used the method of writing in Delphi that you will use it to write within your program or will write as function in binary file. It will be more convenient in using that has how to write like the following, Read the rest of this entry »

May 3rd, 2008

C++ communicate Parallel Port and Serial Port

C language is the one of good complier for interface program via Serial Port,Parallel Port,Card I/O 8255 with output devices.

Programming Microsoft Visual C++ 6 communicating Parallel Port

Outp(port,bytedata)

Send value out port as byte

Outpw(port,worddata)

Send value out port as word

Such as Outp(0×378,0xF1)

Outpd(port,worddata)

Send value out port as byte double words.

inp(port)

Read value as byte from port

inpw(port)

Read value as word from port.

Such as inpw(0×378)

inpd(port)

Read value as double words from port.

You can notice that the structure of function is like programming by VB because Dll File that is used in VB that is written from C. I will not mention the fundamental of communicating port. Read the rest of this entry »

May 2nd, 2008

Programming in Visual C++ 6 to connect with I/O Parallel Port

I have already mentioned the content about C, C++, connecting with PC Port. It’s not too hard. It’s hard at graphics that we write to put together with using, especially program ran on DOS. In this present, programming as Visual is populating because it can be GUI conveniently and not too hard. So, I try to use Microsoft Visual Basic 6 that is in Microsoft Visual Studio 6, for function and step of programming code for connecting port is not much because wizard program of MS VC++6, is created all for us.

In this program, we will use file conio.h that is include file for using function _outp() and _inp()

In this section, I will do as explanation with pictures (Visual Learning), controlling with messages and the arrange of number shown because if you write explanation as the last contexts, you will be hard to understand. Read the rest of this entry »

May 2nd, 2008

C++ communicate Serial Port as polling

I present you about programming by C, version that runs on DOS because there is easier explanation than program as visual that runs on Window that you can notice the article about MS VC++ 6 communicating with Parallel Port and also you can write and try to do by yourself. You can use TurboC because just 1 Mb compiler.

From the part 1, I mentioned about communication as interrupt. In this part, I will present you about communication as polling. The working like this, the flow of data will not be smooth. CPU cannot anticipate that when the new data arrive. It will verify the time with getting and sending data by speed rate that is higher than speed rate that send through keyboard. Read the rest of this entry »

May 2nd, 2008

C++ communicate Serial Port as interrupt

It’s C/C++ in programming to communicate with Serial Port or comport (RS-232). The program I recommend here can communicate between two computers that can send message to each other as interrupt.

For here, we will use Borland C as complier, but you will see me use // that I make for programming explanation. There will be code for reference inter like the following,

Intervector –> use setvect()function for setting the value of IRQ

Intervector –> use getvect()function for the value of IRQ

Intervector –> use for setting of Programmable Interrrupt Controller

Intervector –> use for setting in order to cancel using intervector

Comm Setting –> will use the value in setting rate of Baud rate, the number of bit in transferring data, stop bit, control register FIFO, open DTR-RTS-OUT2. Read the rest of this entry »

« Previous Entries |
cheapest online diazepam 24 hour delivery cheap levitra rx pills buy lorazepam cheap cialis buy cheapest generic valium purchase new report female zyban order oxazepam prescription cheapest generic xanax viagra order herbal klipal for woman levitra buy drugs online buy herbal tramadol cialis soft tabs levitra cialis best herbal viagra soft tabs uk cialis buy viagra on line viagra levitra women buy cialis online without prescription natural levitra substitutes cheapest generic viagra cyber pharmacy propecia viagra soft tabs studies women
Close
E-mail It