Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $nasmPath = "C:\Program Files (x86)\Nasm"
- $virtualBoxPath = "C:\Program Files\Oracle\VirtualBox"
- $env:Path += ";" + $nasmPath
- $env:Path += ";" + $virtualBoxPath
- $objPath = "asm"
- $examplePath = "asm/examples"
- $binPath = "bin"
- $vmName = "MyBootable"
- $asms = "mbc.asm", "mbr.asm", "sector0.asm"
- $examples = "example1.asm", "example2.asm", "example3.asm", "example4.asm"
- Function Clean() {
- VBoxManage unregistervm $vmName --delete
- [string]::Format("{0}/{1}", $objPath, "*.o") | rm
- [string]::Format("{0}/{1}", $examplePath, "*.o") | rm
- [string]::Format("{0}/{1}", $binPath, "*") | rm
- }
- Function Compile() {
- ni bin/disk.img -ItemType file
- foreach ($asm in $asms) {
- $path = [string]::Format("{0}/{1}", $objPath, $asm)
- $obj = $path.Replace(".asm", ".o")
- nasm $path -o $obj
- gc -Enc Byte $obj | ac bin/disk.img -Enc Byte
- }
- foreach ($example in $examples) {
- $path = [string]::Format("{0}/{1}", $examplePath, $example)
- $obj = $path.Replace(".asm", ".o")
- nasm $path -o $obj
- gc -Enc Byte $obj | ac bin/disk.img -Enc Byte
- }
- }
- Function VBoxRun() {
- VBoxManage convertfromraw bin/disk.img bin/disk.vdi
- VBoxManage createvm --name $vmName --register
- VBoxManage storagectl $vmName --name "DiskController" --add ide `
- --bootable on
- VBoxManage storageattach $vmName --storagectl "DiskController" --port 0 `
- --device 0 --type hdd --medium bin/disk.vdi
- VBoxManage startvm $vmName
- }
- if ($Args[0] -ieq "clean") {
- Clean
- }
- elseif ($Args[0] -ieq "compile") {
- Clean
- Compile
- }
- elseif ($Args[0] -ieq "vbox-run" -or $Args.Length -eq 0) {
- Clean
- Compile
- VBoxRun
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement