flat assembler
Message board for the users of flat assembler.

Index > OS Construction > what is 0x12 ?

Author
Thread Post new topic Reply to topic
MaaSTaaR



Joined: 09 Aug 2005
Posts: 8
Location: Kuwait
MaaSTaaR
Hello Smile

please for what 0x12 ? and how i can use it ?

i see this code in koolOS

Code:
int ramsize(void)
{
 int _rsize;
 asm int 0x12;
 asm mov [_rsize], ax;
 return _rsize;
}
    


Smile
Post 21 Aug 2005, 23:53
View user's profile Send private message Reply with quote
adefeo



Joined: 12 Jan 2004
Posts: 46
Location: Bellmore, Long Island, New York
adefeo
Interrupt 0x12 gets the system's memory size and stores it in AX. It is limited to detecting a max of 640KB (or is it 1024KB?), though.
Post 22 Aug 2005, 00:07
View user's profile Send private message Visit poster's website AIM Address Reply with quote
MaaSTaaR



Joined: 09 Aug 2005
Posts: 8
Location: Kuwait
MaaSTaaR
ok is this BOIS Interrupt , and is this Interrupt have other functions ?
Post 22 Aug 2005, 00:10
View user's profile Send private message Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius
That's 12 hexadecimal - if you have no idea what hexadecimal is, check out this tutorial: http://www.dark-logic.com/pgm/binary.html

In FASM, a hex (short for hexadecimal) number is distinguished from decimal numbers (your normal numbers, from 0 to 9) by being preceded by "0x" or "$", or followed by a "h".

Thus, "0x12", "$12", and "12h" are all 12 hexadecimal, which is 18 decimal, 22 octal, or 10010 binary (and can therefore be typed as "18", "22o", or "10010b").

If you program in assembly, you should understand binary and hexadecimal at least, and possibly octal (though it's an old number system no longer used very often).

BTW, Interrupt 12 hexadecimal is the BIOS call (used in DOS) to find out how much memory is on your system. It never says more than 640k though, as it's not possible to access any memory above that under DOS. INT 12h returns the size of memory in kilobytes in AX, and the code there copies AX into _rsize.
Post 22 Aug 2005, 00:11
View user's profile Send private message AIM Address Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius
No, getting the memory size is the only function.
Post 22 Aug 2005, 00:26
View user's profile Send private message AIM Address Reply with quote
MaaSTaaR



Joined: 09 Aug 2005
Posts: 8
Location: Kuwait
MaaSTaaR
Hello Smile

thank you very much THEWizardGenius for this greate informations .

ok i will read this tutorial later Smile

Quote:

Thus, "0x12", "$12", and "12h" are all 12 hexadecimal, which is 18 decimal, 22 octal, or 10010 binary (and can therefore be typed as "18", "22o", or "10010b").

do you mean i can write last code like this

Code:
int ramsize(void)
{
 int _rsize;
 asm int 12h;
 asm mov [_rsize], ax;
 return _rsize;
} 
    


or this

Code:
int ramsize(void)
{
 int _rsize;
 asm int $12;
 asm mov [_rsize], ax;
 return _rsize;
} 
    


Quote:

If you program in assembly, you should understand binary and hexadecimal at least, and possibly octal (though it's an old number system no longer used very often).

of course i understood binary and hex i read this http://www.groovyweb.uklinux.net/index.php?page_name=assembly%20language%20how%20to

but i don't know about octal i will googling Smile .

and i have question please , can i found list of these Interrupt (BOIS Interrupt)

thank you very much Smile
Post 22 Aug 2005, 00:34
View user's profile Send private message Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius
Yes, you can write the code like either of those, in FASM. However, your code appears to be in C, and in C, you can ONLY have the first example (with "0x"), "$" and "h" won't work.

Here's a good reference of the interrupts and what they do: http://www.xaff.org/GI/biosref.html

For example, writing to the screen. This says
Quote:

Int 10h, function 0Eh : write a character
INPUT
AH 0Eh
AL ASCII code of the character
BL Forescreen color of the character

OUTPUT
None

DESCRIPTION :
A character is written to the current location of the cursor in the current screen page. The color of the previous character at this position is kept.
This function handles the various command codes (bell, carriage return...) as command codes. For instance, the output of the "bell" character will produce a beep.
When a character is written with this command, the position of the cursor is incremented. If the last position of the screen is reached, the content of the screen is moved one line up and the character will be written to the first column of the last line of the screen.
The forescreen color is only valid in graphics mode. The value is used to select a color in the current palette.
The content of registers BX, CX, DX, SS, CS and DS isn't modified by this function. All other registers may have been modified.


So we make sure ah is 0Eh, al is the ASCII code of the character (or in FASM, the character itself in single quotes, such as: 'A'), and call INT 10h (BL only matters in graphics mode). In plain FASM (not C):
Code:
mov ah, 0Eh
mov al, 'H'
int 10h
mov al, 'i'
int 10h
mal al, '!'
int 10h

int 20h ;This exits the program, otherwise your computer will crash.
    

and of course, the output should be
Quote:

Hi!
Post 22 Aug 2005, 00:48
View user's profile Send private message AIM Address Reply with quote
MaaSTaaR



Joined: 09 Aug 2005
Posts: 8
Location: Kuwait
MaaSTaaR
THEWizardGenius wrote:
Yes, you can write the code like either of those, in FASM. However, your code appears to be in C, and in C, you can ONLY have the first example (with "0x"), "$" and "h" won't work.

Here's a good reference of the interrupts and what they do: http://www.xaff.org/GI/biosref.html

For example, writing to the screen. This says
Quote:

Int 10h, function 0Eh : write a character
INPUT
AH 0Eh
AL ASCII code of the character
BL Forescreen color of the character

OUTPUT
None

DESCRIPTION :
A character is written to the current location of the cursor in the current screen page. The color of the previous character at this position is kept.
This function handles the various command codes (bell, carriage return...) as command codes. For instance, the output of the "bell" character will produce a beep.
When a character is written with this command, the position of the cursor is incremented. If the last position of the screen is reached, the content of the screen is moved one line up and the character will be written to the first column of the last line of the screen.
The forescreen color is only valid in graphics mode. The value is used to select a color in the current palette.
The content of registers BX, CX, DX, SS, CS and DS isn't modified by this function. All other registers may have been modified.


So we make sure ah is 0Eh, al is the ASCII code of the character (or in FASM, the character itself in single quotes, such as: 'A'), and call INT 10h (BL only matters in graphics mode). In plain FASM (not C):
Code:
mov ah, 0Eh
mov al, 'H'
int 10h
mov al, 'i'
int 10h
mal al, '!'
int 10h

int 20h ;This exits the program, otherwise your computer will crash.
    

and of course, the output should be
Quote:

Hi!


thank you very much man , in fact it's very useful informations Smile
Post 22 Aug 2005, 01:00
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.