Passing arguments between functions
Posted: Sun Feb 22, 2015 4:26 am
Hi,
i habe the following Problem:
Im passing a function an argumten as 0x03F8 and get it back on the other end as 25.
Has anyone an idea what im doning wrong?
void main()
{
/* You would add commands after here */
/* ...and leave this loop in. There is an endless loop in
* 'start.asm' also, if you accidentally delete this next line */
init_video();
unsigned short ComPort = COM1;
serialInit(ComPort);
serialWrite(ComPort, 0x41);
puts("Hello Chat!!!");
for (;;);
}
void serialInit(unsigned short ComPort)
{
unsigned char config;
ComPort = 0x03F8;
//disable interrupts
outportb(INTERRUPT_ENABLE_PORT(ComPort), 0x00);
//boud rate divisor
outportb(LINE_CONTROL_PORT(ComPort), ENABLE_DLAB);
outportb(DLAB_LOW_BYTE_PORT(ComPort), BAUD_RATE_DIVISOR & 0x00FF);
outportb(DLAB_HIGH_BYTE_PORT(ComPort), BAUD_RATE_DIVISOR & 0xFF00);
config = 0x03; //length of 8 bits, no parity bit, one stop bit and break control disabled.
outportb(LINE_CONTROL_PORT(ComPort), config);
config = 0xC7; //FIFO Buffer
outportb(FIFO_CONTROL_PORT(ComPort), config);
config = 0x03; //RTS=1 DTS=1
outportb(MODEM_CONTROL_PORT(ComPort), config);
}
GDB Output:
(gdb) c
Continuing.
Breakpoint 1, main () at main.c:60
60 {
(gdb) n
66 init_video();
(gdb)
67 unsigned short ComPort = COM1;
(gdb)
68 serialInit(ComPort);
(gdb) p /x ComPort
$1 = 0x3f8
(gdb) c
Continuing.
Breakpoint 2, serialInit (ComPort=25) at serial.c:18
18 {
Thanks for any answer!
i habe the following Problem:
Im passing a function an argumten as 0x03F8 and get it back on the other end as 25.
Has anyone an idea what im doning wrong?
void main()
{
/* You would add commands after here */
/* ...and leave this loop in. There is an endless loop in
* 'start.asm' also, if you accidentally delete this next line */
init_video();
unsigned short ComPort = COM1;
serialInit(ComPort);
serialWrite(ComPort, 0x41);
puts("Hello Chat!!!");
for (;;);
}
void serialInit(unsigned short ComPort)
{
unsigned char config;
ComPort = 0x03F8;
//disable interrupts
outportb(INTERRUPT_ENABLE_PORT(ComPort), 0x00);
//boud rate divisor
outportb(LINE_CONTROL_PORT(ComPort), ENABLE_DLAB);
outportb(DLAB_LOW_BYTE_PORT(ComPort), BAUD_RATE_DIVISOR & 0x00FF);
outportb(DLAB_HIGH_BYTE_PORT(ComPort), BAUD_RATE_DIVISOR & 0xFF00);
config = 0x03; //length of 8 bits, no parity bit, one stop bit and break control disabled.
outportb(LINE_CONTROL_PORT(ComPort), config);
config = 0xC7; //FIFO Buffer
outportb(FIFO_CONTROL_PORT(ComPort), config);
config = 0x03; //RTS=1 DTS=1
outportb(MODEM_CONTROL_PORT(ComPort), config);
}
GDB Output:
(gdb) c
Continuing.
Breakpoint 1, main () at main.c:60
60 {
(gdb) n
66 init_video();
(gdb)
67 unsigned short ComPort = COM1;
(gdb)
68 serialInit(ComPort);
(gdb) p /x ComPort
$1 = 0x3f8
(gdb) c
Continuing.
Breakpoint 2, serialInit (ComPort=25) at serial.c:18
18 {
Thanks for any answer!