flat assembler
Message board for the users of flat assembler.

Index > Windows > I/O in assmbly

Author
Thread Post new topic Reply to topic
ishkabible



Joined: 13 Sep 2010
Posts: 54
ishkabible 14 Nov 2010, 04:07
how do i get the port of file path? i see that I/O with out any clib functions requires the in and out instructions witch reqiure a port. how do i obtain this port?
Post 14 Nov 2010, 04:07
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 14 Nov 2010, 06:18
You don't. in and out is for other uses. You won't use them unless you get into OS/driver dev. You must use the interfaces provided, such as WinAPI and libc. You would use those APIs just as you would in C, but you have to add the functions you wish to use to an import list. vid has a good example of calling libc from asm, here.
Post 14 Nov 2010, 06:18
View user's profile Send private message Reply with quote
ishkabible



Joined: 13 Sep 2010
Posts: 54
ishkabible 15 Nov 2010, 01:38
ok ya OS/driver dev is beyond me at this point. so i could access my gpu this way? not that it is at my skill level to do any thing with it just wondering
Post 15 Nov 2010, 01:38
View user's profile Send private message Reply with quote
ishkabible



Joined: 13 Sep 2010
Posts: 54
ishkabible 15 Nov 2010, 02:33
i have a question that dose not pertain to this. i was using idiv and i devided -45 by 15 but the answer that came out was 286331150. what is causing this? any time i divide a negative number it acts like its unsigned.
Post 15 Nov 2010, 02:33
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 15 Nov 2010, 03:05
Quote:
ok ya OS/driver dev is beyond me at this point. so i could access my gpu this way? not that it is at my skill level to do any thing with it just wondering
Not necessarily, you'd have to get access to proprietary(ie closed) information to find out exactly how to manipulate your GPU.

Quote:
i have a question that dose not pertain to this. i was using idiv and i devided -45 by 15 but the answer that came out was 286331150. what is causing this? any time i divide a negative number it acts like its unsigned.
Try dividing 45 by -15. Just a guess.
Post 15 Nov 2010, 03:05
View user's profile Send private message Reply with quote
ishkabible



Joined: 13 Sep 2010
Posts: 54
ishkabible 15 Nov 2010, 03:34
Quote:
Quote:
i have a question that dose not pertain to this. i was using idiv and i devided -45 by 15 but the answer that came out was 286331150. what is causing this? any time i divide a negative number it acts like its unsigned.
Try dividing 45 by -15. Just a guess.


that works but not the other way around whats the deal?

edit: about the other thing. how come some one hasn't figured out this information. i mean it's our computers right? maybe there is no use for this sort of thing. i guess gpu's are meant to be for graphics and aren't much good much else. who knows the infmation? hardware manufacturers like ATI and Nvidia or software developers like OpenGL and DirectX?
Post 15 Nov 2010, 03:34
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 15 Nov 2010, 03:56
Quote:

that works but not the other way around whats the deal?
My hypothesis was that the first operand is unsigned and the second is signed, apparently I was right.

Quote:

edit: about the other thing. how come some one hasn't figured out this information. i mean it's our computers right? maybe there is no use for this sort of thing. i guess gpu's are meant to be for graphics and aren't much good much else. who knows the infmation? hardware manufacturers like ATI and Nvidia or software developers like OpenGL and DirectX?
The people who code the libraries for accessing GPUs either have access to the information from ATI/Nvidia, or have reverse engineered one of their drivers. I think there's a project for a reversed Nvidia driver for Linux. ATI recently released a small amount of documentation, but it's only a small step in the right direction. http://www.x.org/docs/AMD/
Post 15 Nov 2010, 03:56
View user's profile Send private message Reply with quote
ishkabible



Joined: 13 Sep 2010
Posts: 54
ishkabible 15 Nov 2010, 04:10
so i how do i avoid this unsigned vs signed deal, i thought those kind of things weren't specified in assembly and that it was the instruction that dealt with this. i used idiv and idiv is sigend no?

here is my sample program that shows my problem.

Code:
format PE console
entry main

include 'INCLUDE\MACRO\import32.inc'
include 'INCLUDE\MACRO\proc32.inc'

section '.data' data readable writeable

pausemsg db "pause>nul",0
saynum db "%i is the number",10,0
mynumber1 dd ?
mynumber2 dd -45
mynumber3 dd 15

section '.code' code readable executable

main:
        mov edx,0
        mov eax,[mynumber2]
        mov ebx,[mynumber3]
        div ebx
        mov [mynumber1],eax
        push eax
        push saynum
        call [printf]
        add esp,8
        push pausemsg
        call [system]
        add esp,4
        ret


section '.idata' import data readable
library msvcrt,'msvcrt.dll'

import msvcrt,\
printf,'printf',\
scanf,'scanf',\
system,'system',\
getchar,'getchar',\
realloc,'realloc',\
malloc,'malloc',\
free,'free',\
calloc,'calloc',\
exit,'exit'
    
Post 15 Nov 2010, 04:10
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 15 Nov 2010, 05:37
I mean that it expects the first operand to be unsigned(ie the highest bit makes it bigger), instead of signed(ie the highest bit makes it negative). Although they aren't specified, they still make a big difference when interpreted differently. For example, take 45, and print it as "%u" to printf, then negate it, using neg, and print that as unsigned.
Post 15 Nov 2010, 05:37
View user's profile Send private message Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 295
Alphonso 15 Nov 2010, 09:37
Code:
        mov eax,[mynumber2]
        cdq                   ;sign extend eax -> edx:eax
        mov ebx,[mynumber3]
        idiv ebx    
Post 15 Nov 2010, 09:37
View user's profile Send private message Reply with quote
ishkabible



Joined: 13 Sep 2010
Posts: 54
ishkabible 15 Nov 2010, 17:11
ok so so what dose cdq do exactly?
Post 15 Nov 2010, 17:11
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 15 Nov 2010, 18:51
ishkabible,

Alphonso already wrote that: cdq sign-extends eax into edx, i.e. edx==-1 if eax<0, edx==0 otherwise. After this edx:eax contains 64-bit signed representation of the same number as 32-bit signed in eax.
Post 15 Nov 2010, 18:51
View user's profile Send private message Reply with quote
ishkabible



Joined: 13 Sep 2010
Posts: 54
ishkabible 15 Nov 2010, 21:35
ok i get it uses eax joined with edx so that if edx is zero it would be like eax was unsigned because the highest order bit of edx:eax is 0 not 1. thanks guys Smile
Post 15 Nov 2010, 21:35
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.