Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Link to a couple of DOS's written in NASM

49 views
Skip to first unread message

Rod Pemberton

unread,
Apr 3, 2008, 4:49:16 AM4/3/08
to

Frank Kotler

unread,
Apr 3, 2008, 8:31:26 AM4/3/08
to
Rod Pemberton wrote:
> http://litux.wz.cz/htm/download.htm#ltdos

Great stuff! I haven't gotten it to actually work, beyond the "here I
am!" test. Assembles without complaint, except he got bitten by the
"pause bug". Hey, it's *not* Nasm's fault Intel made "pause" an
instruction! A lot of people used "pause" as a label, and their code
broke. (prepend a '$', and Nasm will know it's not an instruction, but
will still know the symbol) Annie always used to use "pozz" - ahead of
the curve! One warning about "label alone on a line" - harmless and
easily fixed. Nice, well-commented (in English!) code. I'm impressed!

I'll get back into this - delightfully small, I wanna see it work!
Thanks, Rod! Thanks Miroslav!

Best,
Frank


Rugxulo

unread,
Apr 3, 2008, 3:25:40 PM4/3/08
to
Hi,

On Apr 3, 7:31 am, Frank Kotler <fbkot...@verizon.net> wrote:
> Rod Pemberton wrote:
> >http://litux.wz.cz/htm/download.htm#ltdos
>
> Great stuff! I haven't gotten it to actually work, beyond the "here I
> am!" test.

I only tested his freeware stuff (some w/ .ASM src: e.g. sachy, lines,
bludiste, planety), not LTDOS or MicroDOS, but he's definitely very
skilled. ;-)

BTW, this isn't the first time someone has written a smaller "lite"
DOS in .ASM: see MiniDOS (FASM src), MikeOS (very basic DOS subsystem,
NASM src), or RxDOS (MASM src originally but ported to A86, link seems
broken but I'll mirror it). Also, supposedly PTS-DOS is pure assembly
(but it's closed src, so I can only guess).

http://board.flatassembler.net/topic.php?t=5275&start=0
http://mikeos.berlios.de/
http://rugxulo.googlepages.com/rxdos_sources_a86.zip

> Assembles without complaint, except he got bitten by the
> "pause bug". Hey, it's *not* Nasm's fault Intel made "pause" an
> instruction! A lot of people used "pause" as a label, and their code
> broke. (prepend a '$', and Nasm will know it's not an instruction, but
> will still know the symbol) Annie always used to use "pozz" - ahead of
> the curve!

Yes, kinda silly since "wait" and "pause" are such common words. NASM
0.98.39 whines BUT the latest NASM 2.02 accepts "pause:" without
complaint (unlike FASM):

---------------------------------------
; works fine in 0.97 or 2.02 but not 0.98.39
org 100h

mov al,'!'
mov cx,15
pause:
int 29h
loop pause
ret
---------------------------------------

It was only after NASM 0.97 that they implemented SSE2, which includes
"pause". And, I'm no SSE expert, but it's supposedly only needed if
looping / testing the value of a variable too often (spin loop??
threaded code??). And the funny thing is it's actually the same thing
as "rep nop", so < P3 processors just ignore it! :-P

Robert Redelmeier

unread,
Apr 3, 2008, 4:01:03 PM4/3/08
to
In alt.lang.asm Rugxulo <rug...@gmail.com> wrote in part:

> Yes, kinda silly since "wait" and "pause" are such common words.

So common they are both Intel x86 instructions.
(WAIT often written as FWAIT for x87 sync).

Would you expect to be able to use `add` as a label?
Some symobls just get reserved to simplify compliers
and assemblers.


-- Robert

Herbert Kleebauer

unread,
Apr 3, 2008, 5:37:19 PM4/3/08
to
Robert Redelmeier wrote:

> Would you expect to be able to use `add` as a label?

Can you give me any logical reason why "add", "mov" or "nop"
can't be used as a label. A label is a label and an opcode
is an opcode. And if an assembler can't distinct between
them, it doesn't deserve the name assembler.

Rod Pemberton

unread,
Apr 3, 2008, 8:21:11 PM4/3/08
to

"Robert Redelmeier" <red...@ev1.net.invalid> wrote in message
news:3IaJj.8$%41...@nlpi064.nbdc.sbc.com...

Yes, to quote myself ( "Calculating checksums..." thread on a.l.a):

"Some assemblers don't have a problem distinguishing between register
names and labels. And, it's requires extra work to properly code a FORTH
interpreter on an assembler that doesn't... I.e., these should be legal but
aren't in NASM - they have to be decorated with underscores... (from two
actual FORTH interpreters written in MASM):

; assembler psuedo-instruction DD as a symbol
DD EQU 0

; LEAVE instruction as a label
LEAVE:
DW LEAVE
jmp LEAVE
"

Rod Pemberton

Rod Pemberton

unread,
Apr 3, 2008, 8:32:38 PM4/3/08
to
"Frank Kotler" <fbko...@verizon.net> wrote in message
news:47F4DC45...@verizon.net...

> Rod Pemberton wrote:
> > http://litux.wz.cz/htm/download.htm#ltdos
>
> Great stuff! I haven't gotten it to actually work, beyond the "here I
> am!" test.

Further than me... I'm not sure how to start them. They're not a device
driver despite the .SYS extension. It seemed to be setup as like a
bootloader, but the segments seemed to be off (wasn't around 0x7c00...). I
wrote them to a .img. QEMU didn't like that!!! (with or without corrected
segments). Maybe I should've tried a normal floppy boot... or the .COM
option.

> Assembles without complaint, except he got bitten by the
> "pause bug".

I used the include nasm16.exe... Perhaps, that wasn't the right choice.

> Nice, well-commented (in English!) code. I'm impressed!

Being a bit paranoid, it makes me wonder... His English seem a bit too good
to you?


Rod Pemberton

Hendrik Schmieder

unread,
Apr 4, 2008, 4:15:18 PM4/4/08
to
Rugxulo schrieb:

>
> Hi,
>
> On Apr 3, 7:31 am, Frank Kotler <fbkot...@verizon.net> wrote:
> > Rod Pemberton wrote:
> > >http://litux.wz.cz/htm/download.htm#ltdos
> >
> > Great stuff! I haven't gotten it to actually work, beyond the "here I
> > am!" test.
>
> I only tested his freeware stuff (some w/ .ASM src: e.g. sachy, lines,
> bludiste, planety), not LTDOS or MicroDOS, but he's definitely very
> skilled. ;-)
>
> BTW, this isn't the first time someone has written a smaller "lite"
> DOS in .ASM: see MiniDOS (FASM src), MikeOS (very basic DOS subsystem,
> NASM src), or RxDOS (MASM src originally but ported to A86, link seems
> broken but I'll mirror it). Also, supposedly PTS-DOS is pure assembly
> (but it's closed src, so I can only guess).
>

There was an official CD with source code of PTS DOS.

Hendrik

Robert Redelmeier

unread,
Apr 4, 2008, 3:58:17 PM4/4/08
to
In alt.lang.asm Rod Pemberton <do_no...@nohavenot.cmm> wrote in part:

> ; assembler psuedo-instruction DD as a symbol
> DD EQU 0

'mkay, then how about redefining pseudo-op EQU as a symbol???

EQU EQU 0

-- Robert

Rugxulo

unread,
Apr 5, 2008, 2:47:43 PM4/5/08
to
Hi,

On Apr 4, 3:15 pm, Hendrik Schmieder <unu...@t-online.de> wrote:
> Rugxulo schrieb:
>
> > Hi,


>
> > BTW, this isn't the first time someone has written a smaller "lite"
> > DOS in .ASM: see MiniDOS (FASM src), MikeOS (very basic DOS subsystem,
> > NASM src), or RxDOS (MASM src originally but ported to A86, link seems
> > broken but I'll mirror it). Also, supposedly PTS-DOS is pure assembly
> > (but it's closed src, so I can only guess).
>
> There was an official CD with source code of PTS DOS.

I've never used PTS-DOS, but I think you're referring to the
unofficial "fork" called Paragon DOS. Some programmers started their
own company selling (more or less) the same thing. And I don't think
the original guys were too pleased. At least, I think Paragon is now
discontinued, but PTS-DOS is still sold (and updated??).

http://en.wikipedia.org/wiki/PTS-DOS
http://www.bttr-software.de/forum/board_entry.php?id=2082#p2120

Rod Pemberton

unread,
Apr 6, 2008, 5:35:51 AM4/6/08
to
"Rod Pemberton" <do_no...@nohavenot.cmm> wrote in message
news:ft3srm$c4t$1...@aioe.org...

> "Frank Kotler" <fbko...@verizon.net> wrote in message
> news:47F4DC45...@verizon.net...
> > Rod Pemberton wrote:
> > > http://litux.wz.cz/htm/download.htm#ltdos
> >
> > Great stuff! I haven't gotten it to actually work, beyond the "here I
> > am!" test.
>

I got the .COM version of MicroDOS to the display the title - if I comment
out his code relocation and wipe in "Shift code behind end of buffers" and
"Clear data buffers" and adjust dx in "Display intro text" in init.asm... I
didn't try to figure out how far it went after that point.

> Further than me... I'm not sure how to start them. They're not a device
> driver despite the .SYS extension.

Doh! Not a device driver .SYS, but an "IO.SYS" .SYS... (Sigh, just a few
of those "one of those days" I guess. ;) SYS A:, COPY (not XCOPY) over
IO.SYS. I tried it for LTDOS. It started... and hung.

LTDOS looks much more complete. It looks like all the pieces are there.
But, I haven't looked enough to tell if he got it all together properly...
I did notice that he seems to think that 0:700 is a good place for the
stack... supposedly below the code (?, what ever happened to 7c00?). If it
goes down, he overwrites the interrupt vectors. Up, his code... I'm
wondering what PC or PC variant this is/was for.

Anyone read Czech? Redelmeier?


Rod Pemberton

Rod Pemberton

unread,
Apr 7, 2008, 9:10:57 AM4/7/08
to
"Robert Redelmeier" <red...@ev1.net.invalid> wrote in message
news:tLvJj.166$vF....@newssvr21.news.prodigy.net...

I let this sit hoping you or someone would comment...

Ignoring that EQU isn't "redefined," do you see some problem with using EQU
as both a symbol and a pseudo-op? (I have to assume that's what you meant.)

I'm not familiar with grammar description languages, but I don't see an
ambiguity... Do you? I.e., each is determinable from context.


Rod Pemberton

Robert Redelmeier

unread,
Apr 8, 2008, 1:09:26 AM4/8/08
to
In alt.lang.asm Rod Pemberton <do_no...@nohavenot.cmm> wrote in part:
> "Robert Redelmeier" <red...@ev1.net.invalid> wrote in message
>> In alt.lang.asm Rod Pemberton <do_no...@nohavenot.cmm> wrote in part:
>> > ; assembler psuedo-instruction DD as a symbol
>> > DD EQU 0
>>
>> 'mkay, then how about redefining pseudo-op EQU as a symbol???
>>
>> EQU EQU 0
>>
>
> I let this sit hoping you or someone would comment...
>
> Ignoring that EQU isn't "redefined," do you see some
> problem with using EQU as both a symbol and a pseudo-op?
> (I have to assume that's what you meant.)

Sure: how would your line [quoted above] work if preceeded by
mine quoted? Which would govern? EQU as symbol or as operator?


-- Robert


Rod Pemberton

unread,
Apr 8, 2008, 4:10:46 AM4/8/08
to
"Robert Redelmeier" <red...@ev1.net.invalid> wrote in message
news:a6DKj.999$2g1...@nlpi068.nbdc.sbc.com...

EQU EQU 0
DD EQU 0

As each, where each is expected.


As given, I'd represent each line as:

<symbol> <pseudo-op EQU> <value>
<symbol> <pseudo-op EQU> <value>

Position 1, i.e., <symbol>, can have a symbol, but not a psuedo-op, in that
location, correct? So, if EQU or DD is in position 1, it can only be
symbol.

Position 2, i.e., <pseudo-op>, can have a psuedo-op (only EQU...), but not a
symbol, in that location, correct? So, EQU in position 2 can only be a
pseudo-op.


Now if we had this:

EQU EQU 0
DD EQU,0

I'd represent each line as, respectively:

<symbol> <pseudo-op EQU> <value>
<pseudo-op DD> <value>, <value>, ...

Again, one can determine each by allowed and disallowed positions and the
additional syntax, i.e., comma or lack of, additional values or lack of,
etc. Let's try these:

DD DD EQU,0,1,3
EQU DD 0

<symbol> <psuedo-op DD> <value>, <value>, ...
<symbol> <psuedo-op DD> <value>, <value>, ...


Combining, we'd still only get two representations:

<symbol> <pseudo-op EQU> <value> ; first rule
<symbol-optional> <psuedo-op DD> <value>, <value>, ... ; second rule

Let's see how some stuff fits:

DD EQU ; second rule
EQU EQU ; doesn't fit either
DD DD ; second rule
EQU DD ; doesn't fit either

DD EQU 0 ; first rule
EQU DD 0 ; second rule
DD DD 0 ; second rule
EQU EQU 0 ; first rule

DD EQU,0 ; second rule
EQU DD,0 ; doesn't fit either
DD DD,0 ; second rule
EQU EQU,0 ; doesn't fit either

DD DD EQU,0,1,3 ; second rule
EQU DD EQU,DD,2,3 ; second rule

It's possible, depending on the rules used, that adding use of pseudo-op's
etc. to an assembler will create ambiguities. But, it's also possible to
select ones that don't conflict. A problem would only arise with an
ambiguity, i.e., a position that (correctly or incorrectly) requires a
symbol or a pseudo-op and could be either. I.e., the language lacks
sufficient syntax or keyword use restrictions to determine which is which.

Isn't the use of EQU as a pseudo-op in assembly limited? Unless I'm
mistaken, everywhere other than "position 2" in the "label EQU value"
syntax, EQU is going to be a symbol or it's value... Yes?


Rod Pemberton

Robert Redelmeier

unread,
Apr 10, 2008, 2:41:47 PM4/10/08
to
In alt.lang.asm Rod Pemberton <do_no...@nohavenot.cmm> wrote in part:
> "Robert Redelmeier" <red...@ev1.net.invalid> wrote in message
>> Sure: how would your line [quoted above] work if preceeded by
>> mine quoted? Which would govern? EQU as symbol or as operator?
>>
>
> EQU EQU 0
> DD EQU 0
>
> As each, where each is expected.
>
>
> As given, I'd represent each line as:
>
> <symbol> <pseudo-op EQU> <value>
> <symbol> <pseudo-op EQU> <value>
>
> Position 1, i.e., <symbol>, can have a symbol,
> but not a psuedo-op, in that location, correct?

Nope.

Most pseudo-ops cannot be proceeded by a symbol.
Some (DD, DW, LABEL, ...) optionally can be.
Very few _must_ be (EQU).

DD EQU 0 could very well be DD 0 0 when EQU EQU 0


-- Robert

Rod Pemberton

unread,
Apr 11, 2008, 11:18:24 AM4/11/08
to
"Robert Redelmeier" <red...@ev1.net.invalid> wrote in message
news:LbtLj.2390$h75...@newssvr27.news.prodigy.net...

> In alt.lang.asm Rod Pemberton <do_no...@nohavenot.cmm> wrote in part:
> > "Robert Redelmeier" <red...@ev1.net.invalid> wrote in message
> >> Sure: how would your line [quoted above] work if preceeded by
> >> mine quoted? Which would govern? EQU as symbol or as operator?
> >>
> >
> > EQU EQU 0
> > DD EQU 0
> >
> > As each, where each is expected.
> >
> >
> > As given, I'd represent each line as:
> >
> > <symbol> <pseudo-op EQU> <value>
> > <symbol> <pseudo-op EQU> <value>
> >
> > Position 1, i.e., <symbol>, can have a symbol,
> > but not a psuedo-op, in that location, correct?
>
> Nope.

Nope? Why not?

(It appears to me that I'm the one defining the syntax to allow exactly that
since you didn't post a different representation...)

Also, I exhibited that there were no problems with that syntax. Do you have
a problem with the exhibits?

> Most pseudo-ops cannot be proceeded by a symbol.

Are you claiming EQU is in the set of "most pseudo-ops"? I.e., that EQU
"cannot be proceeded by a symbol"? If so, I'd wonder why you're exhibiting
confusion, for "<symbol> EQU <value>" has been a staple of _numerous_
assemblers for _decades_... even if we ignore MASM.

> Some (DD, DW, LABEL, ...) optionally can be.
> Very few _must_ be (EQU).
>
> DD EQU 0 could very well be DD 0 0 when EQU EQU 0

Nope.

(At least not as I defined things in my prior post... If you insist on using
text replacement like a C preprocessor, instead of using grammar based
context, then yes, you'll get "DD 0 0". For what I defined, "DD EQU 0" must
be a pseudo-op. If it's not, i.e., if it is "DD 0 0", it will result in
invalid syntax since it's missing comma required for data items that follow
DD. But, hey, you can define a different grammar...)


Rod Pemberton

Robert Redelmeier

unread,
Apr 12, 2008, 4:22:58 PM4/12/08
to
In alt.lang.asm Rod Pemberton <do_no...@nohavenot.cmm> wrote in part:
> "Robert Redelmeier" <red...@ev1.net.invalid> wrote in message
> Also, I exhibited that there were no problems with that
> syntax. Do you have a problem with the exhibits?

Yes. Once [pseudo]ops can optionally be preceded by an
unflagged symbol. interpretation becomes more difficult.

>> Most pseudo-ops cannot be proceeded by a symbol.

> Are you claiming EQU is in the set of "most pseudo-ops"?
> I.e., that EQU "cannot be proceeded by a symbol"?

No, I was speaking numerically, see my next lines:

>> Some (DD, DW, LABEL, ...) optionally can be.
>> Very few _must_ be (EQU).
>>
>> DD EQU 0 could very well be DD 0 0 when EQU EQU 0

> Nope. > (At least not as I defined things in my prior post... If
> you insist on using text replacement like a C preprocessor, instead
> of using grammar based context, then yes, you'll get "DD 0 0".

Exactly what I believe EQU should be. Try using the `gas` [not
gasp] EQU sometime :) For me, one of the most important uses of
EQU is to declare variable locations up top with flexibility:

some_var EQU dword ptr [EBP + 12 ]

then use it indiscriminately in code: ADD EAX, some_var

but if for some reason some_var has to move from a stack
local onto the heap, then all I do is change the declaration,
and the code itself needs _zero_ changes.


-- Robert


Chuck Crayne

unread,
Apr 12, 2008, 5:02:49 PM4/12/08
to
On Sat, 12 Apr 2008 20:22:58 GMT
Robert Redelmeier <red...@ev1.net.invalid> wrote:

> For me, one of the most important uses of
> EQU is to declare variable locations up top with flexibility:

Just as an informational note, in nasm, %define is used for text
substitution, while equ is used for numeric values, and any labels in
the evaluated expression must be defined prior to the equ statement.

--
Chuck
http://www.pacificsites.com/~ccrayne/charles.html


0 new messages