flaneur2020 / fleurix

an unix-like toy os kernel
BSD 3-Clause "New" or "Revised" License
284 stars 60 forks source link

src/kern/entry.S: replace Ruby with NASM macro #10

Closed xuchunyang closed 9 years ago

xuchunyang commented 9 years ago

Here is the ruby code to create abundant and repeating NASM code from src/kern/entry.S:

 NINT = 128
 0.upto(NINT) do |i|
   puts %{
     _hwint#{i}:
       #{'push  dword 0' if i!=17 and (i<8 or i>14)}
       push  dword #{i}
       jmp   _hwint_common_stub
   }
 end

 # generate the vector table
 puts %{
 ; vector table
 [section .data]
 [global  _hwint]

 _hwint:
 }
 0.upto(NINT) do |i|
   puts "  dd _hwint#{i}"
 end

Is it difficult to implement this with nasm macro?

flaneur2020 commented 9 years ago

hmmm, the ruby script is the poor man's macro, maybe it's reasonable to refactor with nasm macro, but i'm not familiar with it, any pull request is welcomed :)