flat assembler
Message board for the users of flat assembler.


Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/privalov/sites/board.flatassembler.net/attach_mod/displaying.php on line 626
Index > DOS > failed dos gui program

Author
Thread Post new topic Reply to topic
kty11



Joined: 30 Dec 2012
Posts: 21
Location: south korea
kty11 05 Jan 2013, 05:35
Hi all
I spend several day to make this
but it never runs... Sad Sad
maybe my coding style is bad.
what I try to do is that..
1. create rectangle with keyboard button 'c'
2. select rectangle and set the rectangle to top(of the screen)

welcome any feedback.
thanks!

_________________
since 1990 November 4th
Post 05 Jan 2013, 05:35
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 05 Jan 2013, 12:59
kty11,

You have to revise your code carefully. For example (check.asm):
Code:
check_top: ;input: al = handle output: bl = 1 or 0
pusha
mov ah, [size_of_struct_window]
;;; (1) Are you sure about proper ds value?
mul al ;al*ah = ah:al
;;; (2) Wrong comment won't change instruction's behavior:
;;; indeed mul al ::== ax = al*al
push cs
pop ds
;;; (3) Here you're setting ds, and at (1) just assuming it
mov di, window_array
add di, ax
add di, top_offset
;;; (4) Meaningless: window_array + top_offset == 2*window_array + 0x8001
popa
;;; (5) Restores all GPRs, including di
mov bl, [ds:di]
;;; (6) di probably has irrelevant value because of (5)
ret    
Your coding style is, well, absent. Not a biggest problem though: your code is simply wrong in many places.
Post 05 Jan 2013, 12:59
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1620
Location: Toronto, Canada
AsmGuru62 05 Jan 2013, 13:28
Yeah, the code is weird.

In COM file you usually do not handle the segment registers.
Since all code and data are in one 64Kb room.

However, if you allocate more data at PSP+64Kb and beyond -- you
do need to set DS,ES for these areas and then restore them back to PSP, so
your data is properly accessed.

So, kty11, what is it you are trying to do?
Do you want to be able to create buttons in any part of screen and click
on them? If so, I'll try to help. But my code style is different from yours.
And how come you do not use structures? It will be impossible to do any GUI
without them.
Post 05 Jan 2013, 13:28
View user's profile Send private message Send e-mail Reply with quote
kty11



Joined: 30 Dec 2012
Posts: 21
Location: south korea
kty11 05 Jan 2013, 14:22
baldr, thank you for your advice.
I don't think I have enough skill for making gui now.
Embarassed Embarassed

and asmguru62, I am happy to be helped.
thank you very much for your kindness.

but at the moment, it seems I need to read the fine manual or exercise easy one first Smile
because I want to learn many from you and others, I need to prepare good questions.
(because good questions leads good advice)
and to prepare question, I need to read fine manual first... Sad

could you suggest me some good resources?
as two of you pointed, I didn't even have no idea how to use ds register
properly
Wink

_________________
since 1990 November 4th
Post 05 Jan 2013, 14:22
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 05 Jan 2013, 17:03
kty11,

Start small. .COM programs are OK for a starter (at least until your program isn't that big). Set up and maintain segment registers (e.g. leave ds==cs and make es==0xA000).

Make program with simple graphic output (dots, lines, rectangles, etc.)
Use that primitives as a library to draw something visually appealing (this will highlight design flaws and code errors).
Refine/refactor source several times (trust me, you'll want to do it real soon).
Add some event-driven framework for input handling.
Consider object-oriented approach.

Bottom-up programming is good to start with, augment it with top-down design and eventually you'll get program that works.

Acquire and learn Turbo Debugger 3.2 (AFAIK it's last real-mode version of it), you're getting nowhere without good debugging tool, and TD was one of the best. As a bonus OllyDbg has similar default keymapping.

And last, but not least: Google is your friend. There are many mode 13h examples (even here).
Post 05 Jan 2013, 17:03
View user's profile Send private message Reply with quote
ACP



Joined: 23 Sep 2006
Posts: 204
ACP 05 Jan 2013, 21:19
baldr wrote:

Acquire and learn Turbo Debugger 3.2 (AFAIK it's last real-mode version of it), you're getting nowhere without good debugging tool, and TD was one of the best.


Actually you can find Turbo Debugger 5 or Turbo Assembler 5.0 packages. They both works under DOS despite availability of TDW which targets Windows 32bit Windows up to Win95 or so. In your case you need to run TD.EXE for debugging DOS files.
Post 05 Jan 2013, 21:19
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 05 Jan 2013, 21:53
ACP,

TD 3.2 was real-mode, without need for DPMI stuff to run. More recent TDs require some PM fiddling to run under DOSBox. And why anybody need DPMI to run plain .COM?

It has some deficiencies as well. Palettes being the least.

I've been told that TD 3.2 can take advantage of TDH386.SYS being loaded in NTVDM and have hardware breakpoints as well. Gotta test it, in a mean time.

Real hardcore players take Bochs and its CLI debugger as the best tool ever. Wink
Post 05 Jan 2013, 21:53
View user's profile Send private message Reply with quote
ACP



Joined: 23 Sep 2006
Posts: 204
ACP 05 Jan 2013, 23:04
Don't know about you but I'm running TD 5 under DosBox 0.74 without any fiddling right now. Don't want to argue with you since this is purly academic discussion but you could always use the same DPMI argument and advice to use debug. It is perfectly suitable for debugging COM files don't you agree? Unless you would like to used hardware breakpoints for example to debug more complex code - those too come handy when debugging even COM files.
Post 05 Jan 2013, 23:04
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 06 Jan 2013, 05:32
ACP,

Yes, it runs; I stand corrected. Not a much time for DOS debugging though: probably that was true for some earlier DOSBox version (cca. 0.50).

Other debuggers that come to my mind are AFD (it was my second one) and QA (perfect for hooking interrupts). And SoftICE as well (probably the most featured, and it has command line too!)

DEBUG is fine for anybody that can use it productively; it's just not easy for beginner. Wink
Post 06 Jan 2013, 05:32
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1620
Location: Toronto, Canada
AsmGuru62 06 Jan 2013, 12:02
DEBUG is ok, but it decodes PUSHA as DB 60h.
Smile
Post 06 Jan 2013, 12:02
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.