News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

making a clock display on screen

Started by scooter4483, October 24, 2005, 02:37:58 PM

Previous topic - Next topic

scooter4483

Hi everyone, i just joined and figured i would get more help here then from my professor.  I have read the rules about coming here. i will not ask anyone to do my homework, though i hope i can get a lot of help here.  long story short.  my class is poorly structured, as is the book and the teacher.  i have to design and implement a digital clock that displays hrs (0-23), min (0-59) and sec (0-59) in a simulated 7-segment format using character graphics in the command window in IA-32 assembly language.  I want to include in my .data the three displays, the hours, minutes, and seconds.  How do I do that?  I know that I will have to write code for each type so that it can display them as well?  How do I implement that?  thanks.

P1

scooter4483,

Welcome to MASMforum!       

Read around the different areas and get a feel for the place.   

Read the help files and tutorials of MASM32.   ( It's better if you download the MASM32 package and install it.  Than use the MSDN distribution of MASM. )

'Search' & Google are your friends for programming.  Then ask your questions.

As far as your digital clock is concerned, there are a number of these around.  Port one if you need to. 

Regards,  P1 

hutch--

Hi scooter,

Welcome on board. Let us know what book you are using and what assembler and tools and we can probably help you. We will also need to know what code you are allowed to use to know if you are restricted to the code with the book or if you can use other code.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

scooter4483

Quote from: hutch-- on October 24, 2005, 11:20:24 PM
Hi scooter,

Welcome on board. Let us know what book you are using and what assembler and tools and we can probably help you. We will also need to know what code you are allowed to use to know if you are restricted to the code with the book or if you can use other code.

I'm using the book: "Assembly Language For Intel-based Computers" 4th Edition.  The assemble im using is MASM 6.15 in IA-32 language.

scooter4483

Quote from: P1 on October 24, 2005, 04:29:51 PM
scooter4483,

Welcome to MASMforum!       

Read around the different areas and get a feel for the place.   

Read the help files and tutorials of MASM32.   ( It's better if you download the MASM32 package and install it.  Than use the MSDN distribution of MASM. )

'Search' & Google are your friends for programming.  Then ask your questions.

As far as your digital clock is concerned, there are a number of these around.  Port one if you need to. 

Regards,  P1 

You say to Search and google for programming.  I tried it and I didnt find anything.  can you help.  Aslo you say that there are a number the digital clocks floating around.  What do you mean by port? Is there one on this site?  Thanks again for your help.

P1

Quote from: scooter4483 on October 25, 2005, 02:00:52 PMWhat do you mean by port? Is there one on this site?
port = translate from one programming language to another.  AFAIK, No.

I have looked around, all of what I found were for DOS with MASM code.  I saw some VB ones to port.  Find one you like and rewrite it.

Regards,  P1  :8)

scooter4483

alright, i went to my ta and got some help.  by that, i mean she barely speaks english.  this is what i have accomplished so far.  instead of dealing with the whole 7 segment thing since i am on a deadline, how would i just display the time?  Im going to be putting it into the display PROC that i started.  here it is:

INCLUDE Irvine32.inc

.data
   Hours       DWORD ?
   Minutes     DWORD ?
   Seconds     DWORD ?
   startTime   DWORD ?
   divisor1    DWORD 1000
   divisor2    DWORD 60

.code

main PROC

CalcTime PROc
   
   callGetMseconds
   mov startTime, eax
   mov edx, 0      ;remainder is initialized to 0
   div divisor1      ;seconds <- milliseconds
   mov edx, 0      ;remainder is set to 0
   div divisor2      ;minutes <- seconds
   mov Seconds, edx   ;remainder is placed into seconds
   mov edx, 0      ;remainder is set to 0
   div divisor2      ;hours <- minutes
   mov Minutes, edx   ;remainder is put into minutes
   mov Hours, eax      ;only hours
   ret
CalcTime ENDP

display PROC
   mov dh, 12      ;row
   mov dl, 40      ;column
   call Gotoxy      ;cursor

scooter4483


hutch--

scooter,

The problem is we don't know what you are alowed to use or if you are restricted to using the libraries from Kip Irvine's book. What you are after is very simple to do but it depends on what you are alowed to use.

You create a SYSTEMTIME structure then fill it with a "GetSystemTime()" API call.


SYSTEMTIME STRUCT
  wYear             WORD      ?
  wMonth            WORD      ?
  wDayOfWeek        WORD      ?
  wDay              WORD      ?
  wHour             WORD      ?
  wMinute           WORD      ?
  wSecond           WORD      ?
  wMilliseconds     WORD      ?
SYSTEMTIME ENDS


In code you create a procedure and perform a local allocation of the SYSTEMTIME structure.


LOCAL stm:SYSTEMTIME

invoke GetSystemTime,ADDR stm


You then pick out each member of the SYSTEMTIME into a WORD (16 bit) register something like this.


    mov ax, stm.wDay


You then work out how you want to display the values you have available.

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

P1

Quote from: scooter4483 on October 24, 2005, 02:37:58 PMHi everyone, i just joined and figured i would get more help here then from my professor.  I have read the rules about coming here. i will not ask anyone to do my homework, though i hope i can get a lot of help here.
Homework has a purpose !  Ask any professor !  And as the rules state, We expect you to do your homework.  It now boils down to, you doing the work and asking questions on sticking points, and not coding/developing it for you.

I have already hinted to you about the code I have already found on the internet.   Some off of other college sites, same home assignment, but it was in DOS. 

Remember this: 
Quote from: P1I have looked around, all of what I found were for DOS with MASM code.  I saw some VB ones to port.  Find one you like and rewrite it.
'Search' & Google are your friends for programming.

I refuse to give you the fish, but I will help in fishing.   :U

Regards,  P1  :8)

hutch--

I am probaly doing too much of your work for you but here is a very simple example that does some of what you need to do. This example shows you how to allocate te structure, fil it using the API call then zero extend it and display the results.


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

comment * -----------------------------------------------------
                        Build this  template with
                       "CONSOLE ASSEMBLE AND LINK"
        ----------------------------------------------------- *

    .code

start:
   
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    call main
    inkey
    exit

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

main proc

    LOCAL stm:SYSTEMTIME                ; allocate the structure as a local

    invoke GetSystemTime,ADDR stm       ; fill the structure with the API call

    movzx eax, WORD PTR stm.wYear       ; ZERO extend structure member into EAX
    print str$(eax)," year",13,10       ; display the value

    movzx eax, WORD PTR stm.wMonth
    print str$(eax)," month",13,10

    movzx eax, WORD PTR stm.wDay
    print str$(eax)," day",13,10

    movzx eax, WORD PTR stm.wHour
    print str$(eax)," hour",13,10

    movzx eax, WORD PTR stm.wMinute
    print str$(eax)," minute",13,10

    movzx eax, WORD PTR stm.wSecond
    print str$(eax)," second",13,10

    movzx eax, WORD PTR stm.wMilliseconds
    print str$(eax)," millisecond",13,10

    ret

main endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end start
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

P1

Hutch did the text based logic.

You still need to come up with the graphical 7 segment display to a window.  And a loop to keep it going.

Hint:  You only need three graphics for your window display routine.

Regards,  P1  :8)

ofg

#12
hi scooter448

Link Edited Out by P1

regards

P1

Now when his Professor takes him to the next step in learning Assembly Language, maybe understanding that this person did do his homework.  We have created an addict to our support.  We did not teach him any skill, beside to how to get code from us.  Which was not the lesson the Professor was trying to teach.

If he had ported one, he could at least have learn the coding techniques.

We failed to really help him.  And we undermined the Professor's goals in teaching.

Just my opinion.

Regards,  P1  :8)