Advertisement
wandrake

Untitled

Aug 18th, 2012
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $nasmPath = "C:\Program Files (x86)\Nasm"
  2. $virtualBoxPath = "C:\Program Files\Oracle\VirtualBox"
  3.  
  4. $env:Path += ";" + $nasmPath
  5. $env:Path += ";" + $virtualBoxPath
  6.  
  7. $objPath = "asm"
  8. $examplePath = "asm/examples"
  9. $binPath = "bin"
  10. $vmName = "MyBootable"
  11.  
  12. $asms = "mbc.asm", "mbr.asm", "sector0.asm"
  13. $examples = "example1.asm", "example2.asm", "example3.asm", "example4.asm"
  14.  
  15. Function Clean() {
  16.     VBoxManage unregistervm $vmName --delete
  17.    
  18.     [string]::Format("{0}/{1}", $objPath, "*.o") | rm
  19.     [string]::Format("{0}/{1}", $examplePath, "*.o") | rm
  20.     [string]::Format("{0}/{1}", $binPath, "*") | rm
  21. }
  22.  
  23. Function Compile() {
  24.     ni bin/disk.img -ItemType file
  25.  
  26.     foreach ($asm in $asms) {
  27.         $path = [string]::Format("{0}/{1}", $objPath, $asm)
  28.         $obj = $path.Replace(".asm", ".o")
  29.         nasm $path -o $obj
  30.         gc -Enc Byte $obj | ac bin/disk.img -Enc Byte
  31.     }
  32.  
  33.     foreach ($example in $examples) {
  34.         $path = [string]::Format("{0}/{1}", $examplePath, $example)
  35.         $obj = $path.Replace(".asm", ".o")
  36.         nasm $path -o $obj
  37.         gc -Enc Byte $obj | ac bin/disk.img -Enc Byte
  38.     }
  39. }
  40.  
  41. Function VBoxRun() {
  42.     VBoxManage convertfromraw bin/disk.img bin/disk.vdi
  43.     VBoxManage createvm --name $vmName --register
  44.     VBoxManage storagectl $vmName --name "DiskController" --add ide `
  45.       --bootable on
  46.     VBoxManage storageattach $vmName --storagectl "DiskController" --port 0 `
  47.       --device 0 --type hdd --medium bin/disk.vdi
  48.     VBoxManage startvm $vmName
  49. }
  50.  
  51. if ($Args[0] -ieq "clean") {
  52.     Clean
  53. }
  54. elseif ($Args[0] -ieq "compile") {
  55.     Clean
  56.     Compile
  57. }
  58. elseif ($Args[0] -ieq "vbox-run" -or $Args.Length -eq 0) {
  59.     Clean
  60.     Compile
  61.     VBoxRun
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement