Page 1 of 1 [ 6 posts ] 

kmalloc
Hummingbird
Hummingbird

User avatar

Joined: 10 Dec 2013
Age: 34
Gender: Male
Posts: 21

15 Feb 2014, 12:57 am

Sorry for the edit, but: It's a pentium D processor and the assembler I'm using is nasm. I would like to set up an interrupt table for real mode.

It's something like this:

Quote:
dw 0
dw 0x04
dw 0x08
dw 0x0c
dw 0x10
dw 0x14
dw 0x18
dw 0x1c
dw 0x20
dw 0x24
dw 0x28
dw 0x2c
dw 0x30
dw 0x34
dw 0x38
dw 0x3c
dw 0x40
dw 0x44
dw 0x48



Last edited by kmalloc on 15 Feb 2014, 4:00 am, edited 1 time in total.

mr_bigmouth_502
Veteran
Veteran

User avatar

Joined: 12 Dec 2013
Age: 31
Gender: Non-binary
Posts: 7,028
Location: Alberta, Canada

15 Feb 2014, 2:42 am

Which architecture are you coding for? I'm no programmer, but I think it would help if you were more specific about what type of CPU you were working on. ;) Since you mentioned "real mode", I'm going to assume x86.



kmalloc
Hummingbird
Hummingbird

User avatar

Joined: 10 Dec 2013
Age: 34
Gender: Male
Posts: 21

15 Feb 2014, 3:21 am

It's a pentium D processor. I will like to have more knowledge of real mode and I'm stuck.



TallyMan
Veteran
Veteran

User avatar

Joined: 30 Mar 2008
Gender: Male
Posts: 40,061

15 Feb 2014, 3:52 am

bugmenot wrote:
kmalloc wrote:
It's a pentium D processor. I will like to have more knowledge of real mode and I'm stuck.

You've posted what looks like assembler, but if it's assembler code it looks to have no instructions. Without instructions your program will not do anything.


Looks to me like he's posted pure machine code. If he posts the assembler version of the code we might better be able to help. It would also help if he said what processor he's coding for.


_________________
I've left WP indefinitely.


TallyMan
Veteran
Veteran

User avatar

Joined: 30 Mar 2008
Gender: Male
Posts: 40,061

15 Feb 2014, 4:21 am

bugmenot wrote:
TallyMan wrote:
bugmenot wrote:
kmalloc wrote:
It's a pentium D processor. I will like to have more knowledge of real mode and I'm stuck.

You've posted what looks like assembler, but if it's assembler code it looks to have no instructions. Without instructions your program will not do anything.


Looks to me like he's posted pure machine code. If he posts the assembler version of the code we might better be able to help. It would also help if he said what processor he's coding for.

I doubt those numbers are intended to be instructions (each 4-byte dword is just the previous value plus 4)


Ah yes, hadn't noticed that. So all he's posted is a numerical sequence, it isn't even code. Back in the day (long ago) when I did assembly programming for the 6502 processor messing with interrupts was something done with great care. I had a Commodore 64 and my program code used to take over the entire computer banking out the operating system ROM to use the RAM at the same shared address. My code handled all the interrupts as necessary. That was long ago though... in a galaxy far away. LOL.


_________________
I've left WP indefinitely.


Cornflake
Administrator
Administrator

User avatar

Joined: 30 Oct 2010
Gender: Male
Posts: 69,542
Location: Over there

15 Feb 2014, 9:31 am

kmalloc wrote:
Sorry for the edit, but: It's a pentium D processor and the assembler I'm using is nasm. I would like to set up an interrupt table for real mode.
You're misunderstanding what the table is supposed to contain; all you've constructed is a list of numbers (constants) where you should have had a list of destination addresses.
Check out the syntax of DW: http://www.nasm.us/xdoc/2.11/html/nasmd ... tion-3.2.1

Each 4-byte offset into the table points to a seg:ofs destination address - the address of the code which handles that particular interrupt.
So the first entry at offset zero is the address of the code to handle interrupt 0, the second entry at offset 4 is the address of the code to handle int 1, the third at offset 8 is the address for int 2 - and so on.

Here's a worked example in NASM of reading and altering the table:
http://computer-programming-forum.com/4 ... 10cbdb.htm
That code uses a DOS environment to allow it to be executed, but the essential parts are not OS-related; one way of writing an entry is basically this:
Code:
 mov word [es:VECT_NUM * 4 + 0],handler
 mov [es:VECT_NUM * 4 + 2],cs
(obviously ES and CS need to have sane values established elsewhere)

bugmenot wrote:
why, in the year 2014, would you want to work in real mode?! !
Because all x86 processors start in real mode when reset and in order to load an OS (the OP is working on a bootloader), certain operational conditions must be established first.


_________________
Giraffe: a ruminant with a view.