flat assembler
Message board for the users of flat assembler.

Index > DOS > Tutorial: Printing a frame

Author
Thread Post new topic Reply to topic
Ciper



Joined: 01 Jan 2013
Posts: 27
Ciper
As DOS examples are scarce in the FASM bundle, I decided to build a series of examples (at least for my own future reference).

Here is a simple example that displays a 80x23 frame (maybe as the final output of a program):

Code:
org 100h

c equ 0B0h

mov ah,9

mov dx,top_bottom
int 21h
mov dx,middle
rept 21 { int 21h }
mov dx,top_bottom
int 21h

int 20h

top_bottom:
    rept 80 { db c }
    db '$'

middle:
    rept 2 { db c }
    rept 76 { db ' ' }
    rept 2 { db c }
    db '$'
    


Notes:

    - Nested "rept"s are not allowed. This example shows how to fake them.
    - You can't "dup"licate non-numeric data (notably EQUs), hence the "rept"s in data definitions.
    - Tested on FreeDOS.
    - Prog size: 221 bytes.


If we use box drawing characters instead of block characters:

Code:
org 100h

tl equ 0DAh
tr equ 0BFh
bl equ 0C0h
br equ 0D9h
h equ 0C4h
v equ 0B3h

mov ah,9

mov dx,top
int 21h
mov dx,middle
rept 21 { int 21h }
mov dx,bottom
int 21h

int 20h

top:
    db tl
    rept 78 { db h }
    db tr
    db '$'

bottom:
    db bl
    rept 78 { db h }
    db br
    db '$'

middle:
    db v
    rept 78 { db ' ' }
    db v
    db '$'
    


Let's use a double border instead of a single one:


Code:
org 100h

tl equ 0C9h
tr equ 0BBh
bl equ 0C8h
br equ 0BCh
h equ 0CDh
v equ 0BAh

mov ah,9

mov dx,top
int 21h
mov dx,middle
rept 21 { int 21h }
mov dx,bottom
int 21h

int 20h

top:
    db tl
    rept 78 { db h }
    db tr
    db '$'

bottom:
    db bl
    rept 78 { db h }
    db br
    db '$'

middle:
    db v
    rept 78 { db ' ' }
    db v
    db '$'
    


Actually, there is a relationship between the corners' values:

Code:
tl equ 0C9h
bl equ tl-1
tr equ 0BBh
br equ tr+1
    


So you have to remember 2 less ASCII codes.

Size of prog: 302 bytes.
Post 01 Jan 2013, 21:53
View user's profile Send private message Visit poster's website Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 22:08; edited 1 time in total
Post 02 Jan 2013, 00:59
View user's profile Send private message Reply with quote
Ciper



Joined: 01 Jan 2013
Posts: 27
Ciper
Hi HaHaAnonymous,

I have the same stance as you regarding 16-bit DOS programming: I just play with it instead of playing real games with XBox or PS3. Please just spare an hour to write a 10 line DOS program in assembly (I would recommend FreeDOS under VirtualBox) and I am sure you will get the same pleasure as you do from Forza or some such.

What I do seems futile to me most of the time because I don't have any practical use for it; but I know there are young people out there who have to do assembly language programming and are curious enough to interrogate how this ugly segmentation business came about and why; in order to discover it they need to go into the the single-segment COM world, because it is easier to start with. Unfortunately none of the good old DOS/BIOS assembly documentation is available anymore, so I do hands-on exercises in the sake of nostalgia and try to provide simple examples as I go along... Unfortunately without comments because I delete all the code once it runs Sad So they are not proper tutorials, I am afraid Sad

Cheers,
Ciper
Post 02 Jan 2013, 01:56
View user's profile Send private message Visit poster's website Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 22:08; edited 1 time in total
Post 02 Jan 2013, 01:59
View user's profile Send private message Reply with quote
KevinN



Joined: 09 Oct 2012
Posts: 161
KevinN
Theres something about using dos that leaves my with a sharper mind. Maybe its that in the back of my mind im not trying to keep track of all these different processes and programs going on with the muktitasking systems.. And focus on one thing at a timr.
Post 02 Jan 2013, 03:09
View user's profile Send private message Reply with quote
Ciper



Joined: 01 Jan 2013
Posts: 27
Ciper
I absolutely agree; a simpler, closer-to-the-metal programming model makes us feel more in control. If all else fails, there is still DEBUG. Of course, this is all for micro-programming.

However, who knows what is going on under the CLR really? (or has time to investigate?) Let alone monstrosities such as Asp.Net MVC4... They make us more productive at the price of our foregoing all control (giving our souls to Satan?); even the support engineers at M$ don't understand what is going under the hood.

On the other hand a CPU is simple, really; it all started to get complex by M$ making it too complex with their abominable C++ compilers... And their soi-disant frameworks, such as VB and later DotNet...
Post 02 Jan 2013, 03:39
View user's profile Send private message Visit poster's website Reply with quote
nop



Joined: 01 Sep 2008
Posts: 165
Location: right here left there
nop
Ciper wrote:
Unfortunately without comments because I delete all the code once it runs Sad So they are not proper tutorials, I am afraid Sad
why wud u do that surely the source is more valuble than the bin as long as u have fasm handy Wink
Post 03 Jan 2013, 01:54
View user's profile Send private message Reply with quote
Ciper



Joined: 01 Jan 2013
Posts: 27
Ciper
I keep the source in the tutorial body and do not keep the bin at all.
Post 03 Jan 2013, 06:52
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar.

Powered by rwasa.