| | |
Serial Port Communication
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2007
Posts: 10
Reputation:
Solved Threads: 1
first of all, i am using windows xp, and i am using nasm to assemble my code, and djgpp to compile it with driver.c
what i basically want to do is do a chat thing using serial ports, pretty much like Choink23 is trying to do in another thread.
here's the code i've done so far:
this code is not printing anything! i'm not sure if something's wrong with the cable, or something's wrong in the backside of my cpu, or something's wrong with my code. pls help me! thanks
what i basically want to do is do a chat thing using serial ports, pretty much like Choink23 is trying to do in another thread.
here's the code i've done so far:
Assembly Syntax (Toggle Plain Text)
segment .text global _asm_main _asm_main: enter 0,0 pusha mov dx, 0 ;send 'a' through com1 mov al, 'a' mov ah, 1 int 14h mov ah,3 ;check serial port status int 14h ;to check if data is available shr ax,9 ;puts bit8 to the carryflag jc fetch ;if bit8=1, fetch jnc cont ;data is not available fetch: mov dx, 1 ;receives 'a' from com2 mov ah, 2 int 14h mov dl, al ;prints the received charac mov ah, 02h int 21h cont: popa mov eax, 0 leave ret
this code is not printing anything! i'm not sure if something's wrong with the cable, or something's wrong in the backside of my cpu, or something's wrong with my code. pls help me! thanks
•
•
Join Date: Jul 2007
Posts: 10
Reputation:
Solved Threads: 1
i wrote this code:
and when i ran it, it printed e! so does this means something's wrong with my hardware?
this chat thing should be between 2 computers, but since i only have one computer, i just plugged one end of the serial cable to com1, and the other end to com2..
Assembly Syntax (Toggle Plain Text)
segment .text global _asm_main _asm_main: enter 0,0 pusha mov dx,0 ;send 'a' through com1 mov al,'a' mov ah,1 int 14h test ah,80h ;got this thing from ArtofASM jnz error error: mov ah,02 mov dl,'e' int 21h popa mov eax,0 leave ret
and when i ran it, it printed e! so does this means something's wrong with my hardware?
this chat thing should be between 2 computers, but since i only have one computer, i just plugged one end of the serial cable to com1, and the other end to com2..
•
•
Join Date: Jul 2007
Posts: 10
Reputation:
Solved Threads: 1
oh my i just found out that attaching the cable to com1 and the other to com2 to test my code is wrong!
i found out that what i need to do is attach it to com1 and short of short-circuit pins 2 and 3! (i am using a "cross" serial cable, this being specified in our project specifications, including how a cross serial cable looks like)
how do you do that? do i have to stick some piece of metal both on pins 2 and three?
i found out that what i need to do is attach it to com1 and short of short-circuit pins 2 and 3! (i am using a "cross" serial cable, this being specified in our project specifications, including how a cross serial cable looks like)
how do you do that? do i have to stick some piece of metal both on pins 2 and three?
Last edited by toxicboy; Jul 29th, 2007 at 10:51 am.
Your best bet would probably be to look at existing (hopefully *working*) example code which you can find stored away all over the Internet. Here are some links to get you started:
http://www.programmersheaven.com/zone5/mh1.htm
ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/
http://www.textfiles.com/programming/
http://www.nondot.org/sabre/os/artic...cationDevices/
Nathan.
http://www.programmersheaven.com/zone5/mh1.htm
ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/
http://www.textfiles.com/programming/
http://www.nondot.org/sabre/os/artic...cationDevices/
Nathan.
Last edited by Evenbit; Aug 1st, 2007 at 2:55 pm. Reason: forum didn't like one link
while (CPU is present) {some assembly required}
•
•
Join Date: Jul 2007
Posts: 10
Reputation:
Solved Threads: 1
http://www.beyondlogic.org/serial/termpoll.c
above is a code from beyondlogic. i would like to basically translate this code into assembly. i would like to interface c and assembly, having inportb and outportb written in c, and the two fuction being called in asm.
can you pls. give me references on how i could write those functions in c?
above is a code from beyondlogic. i would like to basically translate this code into assembly. i would like to interface c and assembly, having inportb and outportb written in c, and the two fuction being called in asm.
can you pls. give me references on how i could write those functions in c?
The major problem you fase is the operating system you plan to use. MS-Windows and *nix will not permit programs to access the ports directly like that program you posted. Only MS-DOS will permit it.
Search some of these google links to see it they contain anything useful to you.
Search some of these google links to see it they contain anything useful to you.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Jul 2007
Posts: 10
Reputation:
Solved Threads: 1
WHAT IS WRONG WITH THIS CODE? It's not printing anything..
i am compiling using gcc in ms-dos, and is using nasmide to assemble, which is on ms-dos as well..
i am linking this code with these C code for the inport/outport functions
thanks..
edit: also, the termpoll.c is running perfectly in my pc, i ran it on dos. i really dont understand why my asm translation is not working.. i'm stuck
i am compiling using gcc in ms-dos, and is using nasmide to assemble, which is on ms-dos as well..
Assembly Syntax (Toggle Plain Text)
%define port1 3f8h segment .data char dw 'a', 0 format dw "%s", 0 segment .text global _asm_main extern _outportb, _inportb, _printf _asm_main: enter 0,0 pusha push char ;send character to port1 push port1 call _outportb add esp, 8 push port1 ;receive char from port1 call _inportb add esp, 4 ;mov edx, eax ;print received char ;mov ah, 02h ;using assembly ;int 21 ; i tried either way, it's not working push eax ;print using printf push format call _printf add esp, 8 popa leave mov eax, 0 ret
i am linking this code with these C code for the inport/outport functions
Assembly Syntax (Toggle Plain Text)
#include <stdio.h> #include <dos.h> int main() { int ret_status; ret_status = asm_main(); return ret_status; }
thanks..
edit: also, the termpoll.c is running perfectly in my pc, i ran it on dos. i really dont understand why my asm translation is not working.. i'm stuck
Last edited by toxicboy; Aug 15th, 2007 at 6:07 am.
![]() |
Similar Threads
- serial port component for dephi 7 (Pascal and Delphi)
- Send data on a serial port (C++)
- Serial port communication using C++ (C++)
- Problem in developing an Serial Communication Interface (Visual Basic 4 / 5 / 6)
- Serial Port (C++)
- Serial Port (C++)
Other Threads in the Assembly Forum
- Previous Thread: Please help me with this code...
- Next Thread: Question on Interrupts...
Views: 4708 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for Assembly
3d 68hc11 6811 80386 adress array asm assembler assembly boot bootloader buffer compression cursor debug directory division docs dos draw emulator endtask error exceptions file int10h integer intel interrupt interrupts language loop nohau osdevelopment print program range read remainder shape string text theory tsr x86






