News:

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

Help with assembly programming

Started by SepulRise, April 05, 2005, 08:59:37 PM

Previous topic - Next topic

SepulRise

Hi.

How can i made a progamming with assembler to simulate a digital/analogic clock?

Thanks

Darrel

From the information you have provided.

QuoteHow can i made a progamming with assembler to simulate a digital/analogic clock?

Solution:  Learn assembly language and apply knowledge  :8)

Seriously:  Study Iczelion's tutorials at http://spiff.tripnet.se/~iczelion/. I would also suggest going to downloads and get the Win32 API reference. Then ask more specific questions and the people here will be glad to help.  :U

I'm assuming you have already obtained hutch's MASM32

Darrel

dsouza123

There are a few example programs that come with MASM32.
GETTIME.ASM and JACTS.ASM between the two of them
there is plenty of code to learn from to write your own programs.

MichaelW

There is also an LCD-style interface (for a CD player) in \masm32\examples\EXAMPLE6\LCD
eschew obfuscation

SepulRise

Ok.

Thanks.

In this moment i know the source code to make a digital clock , but i dont know i will make a analogic clock.

Can help me?

Thanks

raymond

Obviously, you first need to know how to draw on the screen.

Then you will have to brush up on your trigonometry to compute the direction in which you will need to draw the minute and hour hands (and also to compute the position where you will draw the numbers).

If you don't know any of the above, this may take much longer than you originally thought. :toothy

Raymond
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

SepulRise

ok.

But can you tell me where i can see an example of source code for analogic clock?

SepulRise

I see the example in the site of Ron's Cornucopia for assembly language and graphics programming. This example help me, but contains some functions that i dont work with that.  I work with the MASM613 in school and in my home.

Fuctions i dont work is like that:

include windows.inc

mov   wc.cbSize,SIZEOF WNDCLASSEX

INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
           WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
           CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
           hInst,NULL

.IF edx
       mov pt4[2*8].x,33      ; if edx is true its a minute mark (small circle)
       mov pt4[2*8].y,33
   .ELSEIF

And are more.

SepulRise

In my school the assemlby language is like that (this is a digital clock):

.model small
.stack 100h

.code
extrn Crlf:proc, Writebcd:proc 

main proc
    mov  ax,@data
    mov  ds,ax
   
    call RealClockTime
   
    mov  ax,4C00h
    int  21h
main endp

;---------------------------------------------
; Read and display the real time clock

RealClockTime proc near
    mov   ah,2
    int   1Ah    ; CH=hrs, CL=min, DH=sec, DL=dst flag
    mov   al,ch
    call  Writebcd ; write the hours
    mov   dl,':'
    call  outChar
    mov   al,cl
    call  Writebcd ; write the minutes
    mov   dl,':'
    call  outChar
    mov   al,dh
    call  Writebcd ; write the seconds
    call  crlf
    ret
RealClockTime endp

outChar proc    ; display char in DL
    push  ax
    mov   ah,2
    int   21h
    pop   ax
    ret
outChar endp
end main


Its different in some parts. And its more simple.

GregL

#9
SepulRise,

It looks like you are doing 16-bit DOS programming with MASM in school. This forum is about 32-bit Windows programming with MASM, but there is a '16-bit DOS Programming' subforum here.

[edit] duh! This is the 16-bit DOS Programming forum, sorry. [/edit]

Xor Stance


MichaelW

SepulRise,

If you are doing this as a 16-bit DOS app then perhaps the attachment will provide you with some useful information. It is a QB (QBasic/QuickBASIC) program that draws and updates a graphical clock face in sync with the system time. The code that does the actual graphics is specific to QB, using complex library functions, and no direct translation to MASM code would be possible. The task would be much easier if you had library functions available. If not, you would need to create your own functions to draw, as a minimum, pixels, lines, and circles. The VGA BIOS provides an easy to use function that will allow you to write individual pixels in any of the supported graphics modes. The function is slow, but running on recent hardware it might be fast enough to do the job.  You would still need code to draw lines and circles, even if the code called the BIOS to write the pixels that make up the lines and circles. There should be many examples of such code available. The graphics mode that the QB app uses (VGA BIOS mode 12h) was selected because it provided high resolution. If you need to access the display memory directly, without the aid of library functions, then you should probably try to use mode 13h because the layout of the display memory (from the programmer's perspective) is simpler.



[attachment deleted by admin]
eschew obfuscation

Darrel

SepulRise,

First off:  I am not familiar with 16 bit DOS Programming.

With that said:

include windows.incwindows.inc is a simple text file where all your constants, data types, and structures are defined.

INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInst,NULL: Is a function (proc) call, this particular function is located in user32.dll, therefor you will need the following include statements:

include \masm32\include\user32.inc

includelib \masm32\lib\user32.lib

mov   wc.cbSize,SIZEOF WNDCLASSEX: wc is defined elsewhere as either a local or global variable of type WNDCLASSEX. If you look in the Win32 API reference I mentioned previously you will find the elements of WNDCLASSEX described.

You can also download MASM32 version 8.2 at the same page as you download the Win 32 API reference. MASM32 comes with MASM 6.14. I believe you should be able to use either MASM 6.14 or the version you presently have MASM 6.13.

Regards,

Darrel