Tip: Reducing the repetitive asm code from Bran's tutorial

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post by neon »

not a middle man function that then signals the driver.
The entire HAL is a middle man of sorts. It acts like a motherboard driver between the kernel, kernel level drivers, and the hardware.

The HAL's register function would need to update the entry in the IDT with the new address of the routine that is being registered. Because IRQ's and ISR's are stored within the same table, We don't need to change anything else.

I have not thought about shared interrupts though.

This is still a design-in-progress though :) I still have not found a nice way of loading the HAL with writing a hardware independent memory manager and file manager.

The problem is that of paging and memory management revolves around the hardware. However, placing hardware dependent code for memory management defies the purpose of the HAL in the first place. However, without proper memory management, we cannot have a file manager load programs at a virtual address, anywhere in memory. Thus, cannot load the HAL. (Unless we load it at a specific physical memory address, which is quite ugly.)

Any suggestions for this problem? :/
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Avarok
Member
Member
Posts: 102
Joined: Thu Aug 30, 2007 9:09 pm

Post by Avarok »

Heh, let me try to remember.

Pseudocode:

Code: Select all

%macro push 1-*
  %rep %0
    %push %1
    %rotate 1
  %endrep
%endmacro

; usage:

push eax, ebx, ebp ; uses the macro
push rax ; doesn't qualify for the macro signature, so left as is.

[/code]
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies.
- C. A. R. Hoare
Avarok
Member
Member
Posts: 102
Joined: Thu Aug 30, 2007 9:09 pm

Post by Avarok »

For no real reason, I spent the last four hours working up a start at a HLL using NASM macros.

You can now:

Code: Select all

push ax, bx, cx
pop ax, bx, cx

and get the same order...

ccall my_method, a, b, c
pcall my_method, a, b, c

cret cc

do
..
credo cc

while cc
..
end

if cc
..
end

if cc
..
else
   if cc
   ..
   else
   ..
   end
end
I tried to get it doing once-only imports and methods automatically, but neither worked so well because of limitations with my understanding of how to put ( and " characters next to macro arguments.

fcall, and your own calling conventions are easy, but the for loop is also left to be written.

Perhaps someone can expand on this?
Attachments
macros.txt
(1.47 KiB) Downloaded 51 times
test.asm
(293 Bytes) Downloaded 14 times
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies.
- C. A. R. Hoare
Post Reply