How are you every one?
I have this project and I already have a code and the circuit, but I studied assembly language it's supposed to display the hours and minutes.
Does any one know assembly and c language?
Here's the code: - TITLE CLOCK.ASM
-
DOSSEG
-
.MODEL SMALL
-
.STACK 0100H
-
.DATA
-
PRINTERPORTBASEADDRESS equ 378h
-
-
.CODE
-
MAIN PROC
-
MOV AX, @DATA
-
MOV DS, AX
-
-
CALL RTIME ; READ TIME
-
CALL DisplayTime ;DISPLAY TIME
-
-
MOV AX, 4C00H
-
INT 21H
-
MAIN ENDP
-
-
RTIME PROC
-
MOV AH, 02H
-
INT 1AH
-
RET
-
-
; CH - HOUR
-
; CL - MINUTES
-
; DH - SECONDS
-
RTIME ENDP
-
-
DisplayTime PROC
-
push DX ; was DH
-
push CX ; was CL
-
;
-
mov AL,CH
-
mov DX,PRINTERPORTBASEADDRESS
-
out DX,AL
-
mov AL,01h
-
mov DX,PRINTERPORTBASEADDRESS+2
-
out DX,AL ; enable display
-
call Delay
-
;
-
mov AL,00h
-
mov DX,PRINTERPORTBASEADDRESS+2
-
out DX,AL
-
pop AX ; pop CL (minutes)
-
mov DX,PRINTERPORTBASEADDRESS
-
out DX,AL
-
mov AL,02h
-
mov DX,PRINTERPORTBASEADDRESS+2
-
out DX,AL ; enable display
-
call Delay
-
;
-
mov AL,00h
-
mov DX,PRINTERPORTBASEADDRESS+2
-
out DX,AL
-
pop AX ; pop DH (seconds)
-
mov AL,AH
-
mov DX,PRINTERPORTBASEADDRESS
-
out DX,AL
-
mov AL,08h
-
mov DX,PRINTERPORTBASEADDRESS+2
-
out DX,AL ; enable display
-
call Delay
-
;
-
mov DX,PRINTERPORTBASEADDRESS+2
-
mov AL,00h
-
out DX,AL
-
ret
-
-
DisplayTime ENDP
-
-
Delay Proc
-
MOV CX, 00100h
-
X: PUSH CX
-
MOV CX, 0FFFFh
-
Y: LOOP Y
-
POP CX
-
LOOP X
-
RET
-
-
Delay ENDP
-
END
Thank you for your time.
This is the circuit diagram http://www.electvillage.com/upload//...adbd174136.png 7 3450
Is there a problem with this assembly language program?
But there's small problem with minutes don't work probably
Thank you for time and writing comment
-
-
#define A 0
-
#define B 1
-
#define C 2
-
#define D 3
-
#define E 4
-
#define F 5
-
#define G 6
-
-
typedef struct {int seg[7];} digit_t;
-
-
digit_t disp[4];
-
/*
-
* AAAA
-
* F B
-
* F B
-
* GGGG
-
* E C
-
* E C
-
* DDDD
-
*/
-
-
digit_t int2segs[10] = {
-
/* A B C D E F G */
-
{1, 1, 1, 1, 1, 1, 0}, /* 0 */
-
{0, 1, 1, 0, 0, 0, 0}, /* 1 */
-
{1, 1, 0, 1, 1, 0, 1}, /* 2 */
-
{1, 1, 1, 1, 0, 0, 1}, /* 3 */
-
{0, 1, 1, 0, 0, 1, 1}, /* 4 */
-
{1, 0, 1, 1, 0, 1, 1}, /* 5 */
-
{1, 0, 1, 1, 1, 1, 1}, /* 6 */
-
{1, 1, 1, 0, 0, 0, 0}, /* 7 */
-
{1, 1, 1, 1, 1, 1, 1}, /* 8 */
-
{1, 1, 1, 1, 0, 1, 1} /* 9 */
-
};
-
-
void print_dig (digit_t d, char *name)
-
{
-
int i;
-
-
printf("%s\n", name);
-
for (i=0; i < 7; i++) {
-
printf(" Segment %c : %6d\n", 'A'+ i, d.seg[i]);
-
}
-
}
-
-
void display_dig (digit_t *d, int n)
-
{
-
digit_t symbol;
-
int i;
-
-
if (n > 9) {
-
printf("\n error digit too large \n");
-
exit(1);
-
}
-
symbol = int2segs[n];
-
-
for (i=0; i < 7; i++) {
-
d->seg[i] += symbol.seg[i]; /* Add value for this tick */
-
}
-
}
-
-
void display(int h, int m, int s)
-
{
-
int m1, m10, h1, h10;
-
-
m1 = m%10; /* get individual digits */
-
m10 = m/10;
-
h1 = h%10;
-
h10 = h/10;
-
-
if (h10 > 0) /* leading zero supression */
-
display_dig(&disp[0], h10);
-
display_dig(&disp[1], h1);
-
display_dig(&disp[2], m10);
-
display_dig(&disp[3], m1);
-
}
-
-
main()
-
{
-
int hour, min;
-
-
for (hour = 1; hour <= 12; hour++) {
-
for (min = 0; min < 60; min++) {
-
display(hour, min, 0);
-
}
-
}
-
print_dig(disp[0], "Hours Tens");
-
print_dig(disp[1], "Hours Ones");
-
print_dig(disp[2], "Minutes Tens");
-
print_dig(disp[3], "Minutes Ones");
-
}
Is there any problem if I use it for my project ??
zmbd 5,501
Expert Mod 4TB
loloysh
Just what is it that you're asking?
Are you having errors with this?
I assume the assembly language in your initial post is for an x86-style microprocessor. The x86 architecture allows for both memory-mapped I/O and port I/O. The OUT command used in lines 36,39,44,47,50,55,59,62,67 of the assembly-language program performs port output. Unfortunately for you, port I/O is incompatible with Standard C -- no combination of C instructions will induce the compiler to emit an OUT command. You either need a nonstandard compiler extension or your C program needs a way to invoke explicit assembly language instructions. There are two ways for C code to invoke explicit assembly language instructions: inline via the asm keyword or through a C-callable assembly language subroutine.
These are advanced topics. It would help me to know your familiarity with x86 assembly and C before I go into more detail.
@loloysh: did you write these two programs or are you trying to understand code that somebody else wrote?
It isn't such an advanced topic if your compiler provides a nonstandard library function that does the hard part for you. The following functions are part of the MSDN run-time library (assuming your program executes in a Microsoft environment). - #include <conio.h>
-
int _outp(
-
unsigned short port,
-
int databyte
-
);
-
unsigned short _outpw(
-
unsigned short port,
-
unsigned short dataword
-
);
-
unsigned long _outpd(
-
unsigned short port,
-
unsigned long dataword
-
);
The original assembly language program does a few more tricky things that you need to handle properly in C: - Line 17: INT 21H
- Line 22: INT 1AH
- Lines 72-81: Delay Proc
The link to the circuit diagram wants to install a driver before it will show me the diagram ... I'm not willing to do that. Please describe the important parts of the circuit: - Does each data bit drive a segment of the display or does your circuit include a binary/BCD-to-segment converter?
- If each data bit drives a segment, then are the data bits active high or active low?
- For each digit of the display, what control signal strobes that digit; and is the strobe active high or active low?
- What is the minimum width of the strobe pulses?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: David |
last post by:
I'm wondering if python is capable of fairly precise timing and also sending
data out the parallel port.
For example ; making a 7.5 KHz square wave come out of one of the data pins
on the...
|
by: Loui Mercieca |
last post by:
Hi
I have read and tried the tutorial from the msdn at
http://support.microsoft.com/default.aspx?scid=kb;en-us;823179&Product=vb6
which i really suggest regarding the serial and parallel port.
...
|
by: charles8000 |
last post by:
Hi, I have trouble writing on parallel port using C++. It's been years I have worked with C++, I would need files to use as examples. Thank you for helping...
...
|
by: Wouter van Teijlingen |
last post by:
Dear Readers,
I was reading about how to control the COM and LPT port using VB .NET.
I've found a lot of information, and it was very useful to me. I found
an example program on the site of...
|
by: stephanier |
last post by:
hello!!!
i`m working in a proyect and i need to read the parallel port using assembly...
i have searched in the internet, but did not find any usefull information...
can someone help me??......
|
by: abhi |
last post by:
Hello,
I want to create a small project which will display scrolling text on
LED that will be attached to Parallel port. I want to create this
project in C language(possibly in Mingw) on Windows...
|
by: mravichandran82 |
last post by:
Hi Friends,
I need a detailed discusion and a good example about, how to read parallel port input and output to parallel port through java source code. If u send as mail then I thank u so...
|
by: jasmeetqwertyqwertyqwerty |
last post by:
how to interfere with parallel port using c++ and how to program a robot using c++ code .can any1 also send me a program in c++....m new here i hope u will help.
Thnx in advance.
cya
|
by: abhinav7777 |
last post by:
Hi!!
I'm Final Year Student(CS)..
I'm developing a project which is a prototype of a SPY Vehicle..
I want to know how to access parallel port using C/C++ , VB.Net or Java.
Anybody having...
|
by: ssndk123 |
last post by:
Hi,
Using the UserPort program that changes permissions in XP so that I am
able to write directly to the parallel port using assembler..
I'm trying to send out square wave pulses for x number...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |