flat assembler
Message board for the users of flat assembler.

Index > DOS > How to perform I/O with "use32"

Author
Thread Post new topic Reply to topic
HeadCase



Joined: 08 Jul 2008
Posts: 3
Location: United Kingdom
HeadCase 08 Jul 2008, 14:31
Hi,

I have recently started using FASMD, and managed to develop a reasonably good prime number finder with the "use16" directive, where I use int 21h/xxh to perform I/O to the console.

I would now like to explore the use of 32-bit instructions and data by changing the prime number program to test for primes up to 4 billion.

What I would like to know is:

How do I perform simple I/O, like int 21h/xxh, when using 32-bit instructions (i.e. replacing "use16" with "use32")?

It might help you to formulate a reply if I state that I AM a former 16-bit assembler programmer but my knowledge is phenominally out of date, plus I know nothing about DPMI but the name.

Thanks in advance....

_________________
HeadCase Smile
Post 08 Jul 2008, 14:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19871
Location: In your JS exploiting you and your system
revolution 08 Jul 2008, 15:07
If you are using DOS then you have to find a way to switch the CPU into 32bit mode before you can use use32. DMPI (and similar) may be a good way to start. The DOS version of fasm can use DMPI, have a look at "modes32.inc".
Post 08 Jul 2008, 15:07
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 08 Jul 2008, 15:37
Quote:

I would now like to explore the use of 32-bit instructions and data by changing the prime number program to test for primes up to 4 billion.


But, do you really need more memory? You could just write the 32-bit instructions straight without trouble, the penalty will be that each instruction will take extra space (for the override prefixes) and maybe a little more time to execute.
Post 08 Jul 2008, 15:37
View user's profile Send private message Reply with quote
HeadCase



Joined: 08 Jul 2008
Posts: 3
Location: United Kingdom
HeadCase 08 Jul 2008, 16:35
Hi Revolution and Loco,

Thanks for your replies. Perhaps I haven't explained the situation very well. Let me try again...

I've attached the whole program that I would like to change to find primes to 4 billion.

Is it simply a case of me using DX:AX register pair to perform calculations or do I need to recode as a 32-bit program?


Description:
Download
Filename: New Text Document.txt
Filesize: 18.21 KB
Downloaded: 212 Time(s)


_________________
HeadCase Smile
Post 08 Jul 2008, 16:35
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 08 Jul 2008, 17:23
HeadCase: you can use 32bit registers from 16bit apps, you just can't use 32bit addressing.

Anyway, I'd suggest you take a look at either japheth's HX dos extender, or the old WDOSX extender - those make it easy to write 32bit dos executable, including memory access etc.
Post 08 Jul 2008, 17:23
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 08 Jul 2008, 17:37
Quote:

you just can't use 32bit addressing.

In fact you can but make sure you don't cross the 64KB offset limit with the final calculated address.

Code:
org $100

  mov ah, $09
  mov ebx, table
  mov ecx, -6

  .loop:
    mov dx, [ebx+ecx*2+12]
    int $21

    inc cx
    jnz .loop

  xor ax, ax
  int $16

  int $20


struc Table [string] {
common
  .:
forward
local ..entry
  dw ..entry
forward
  ..entry db string, '$'
}

table Table '1', '2', '3', '4', '5', '6'    
Post 08 Jul 2008, 17:37
View user's profile Send private message Reply with quote
roboman



Joined: 03 Dec 2006
Posts: 122
Location: USA
roboman 10 Jul 2008, 03:03
jezzzzz Dex hasn't chimed in yet !! You could use DexOS Smile
Post 10 Jul 2008, 03:03
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19871
Location: In your JS exploiting you and your system
revolution 10 Jul 2008, 04:20
roboman wrote:
jezzzzz Dex hasn't chimed in yet !! You could use DexOS Smile
DexOS is not an extension for DOS.
Post 10 Jul 2008, 04:20
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1898
DOS386 11 Jul 2008, 07:49
Quote:
I have recently started using FASMD


wow ... the 2nd one Laughing

Quote:
and managed to develop a reasonably good prime number finder with the "use16" directive, where I use int 21h/xxh to perform I/O to the console


Smile

Quote:
I would now like to explore the use of 32-bit instructions and data by changing the prime number program to test for primes up to 4 billion


32-bit instructions indeed do work to some degree in 16-bit RM also ... but better to use DPMI. RTFF ! (FAQ on subforum top) Very Happy Or look at some of my examples.

http://board.flatassembler.net/topic.php?t=8670

Quote:
New Text Document.txt


I wonder whether ^^^ you use DOS at all ...

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 11 Jul 2008, 07:49
View user's profile Send private message Reply with quote
HeadCase



Joined: 08 Jul 2008
Posts: 3
Location: United Kingdom
HeadCase 11 Jul 2008, 13:11
To all who helped with my problem:

I've managed to get my program to calculate primes to above 4 billion - Thanks.

Still have a great deal to learn though. It's obvious from the level of my question that I know very little about the x86 and the various assemblers able to be used on it. I do, however, intend to learn much more about them and you've helped me in the first steps along a very long road.

Thanks again, and keep smilin'...

_________________
HeadCase Smile
Post 11 Jul 2008, 13:11
View user's profile Send private message 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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.