From 03b2e723b02de29731fd8952e23be7707acbbff9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 24 Apr 2019 00:08:19 +0200 Subject: [PATCH] a assembly program for everyone --- .program.asm.swp | Bin 1024 -> 0 bytes Makefile | 19 ++++++++++-- README.md | 6 ++++ beep.asm | 13 ++++---- beep.bin | Bin 75 -> 81 bytes boot.asm | 2 +- boot.bin | Bin 512 -> 512 bytes disk.img | Bin 737280 -> 737280 bytes food.asm | 60 ++++++++++++++++++++++++++++++++++++ food.bin | Bin 0 -> 81 bytes light.asm | 60 ++++++++++++++++++++++++++++++++++++ light.bin | Bin 0 -> 81 bytes program.asm | 74 +++++++++++++++++++++++++++++++++----------- program.bin | Bin 8192 -> 8192 bytes silence.asm | 60 ++++++++++++++++++++++++++++++++++++ silence.bin | Bin 0 -> 81 bytes software.asm | 78 +++++++++++++++++++++++++++++++++++++++++++++++ software.bin | Bin 0 -> 8192 bytes voice.asm | 60 ++++++++++++++++++++++++++++++++++++ voice.bin | Bin 0 -> 81 bytes 20 files changed, 404 insertions(+), 28 deletions(-) delete mode 100644 .program.asm.swp create mode 100644 food.asm create mode 100644 food.bin create mode 100644 light.asm create mode 100644 light.bin create mode 100644 silence.asm create mode 100644 silence.bin create mode 100644 software.asm create mode 100644 software.bin create mode 100644 voice.asm create mode 100644 voice.bin diff --git a/.program.asm.swp b/.program.asm.swp deleted file mode 100644 index bcace04bf4d6b12b7aa79b05779dbc823b61003b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{7E)H7y40vTcq3`P0*B}hUznTfi|IOUKf^fU5vQ}q+|D+)@J^z-sd zaw}6((-KQ_N|JyU<>V)(q!#Iyl;`Ic>lYN|rxzvW>LnKEA{#Ku9u0xf5TGOkLeVt? E0P?6Ct^fc4 diff --git a/Makefile b/Makefile index 1def271..9dea123 100755 --- a/Makefile +++ b/Makefile @@ -3,7 +3,12 @@ all : image compile : nasm -f bin -o boot.bin boot.asm nasm -f bin -o program.bin program.asm + nasm -f bin -o software.bin software.asm + nasm -f bin -o food.bin food.asm nasm -f bin -o beep.bin beep.asm + nasm -f bin -o voice.bin voice.asm + nasm -f bin -o silence.bin silence.asm + nasm -f bin -o light.bin light.asm # nasm -f bin -o program2.bin program2.asm @@ -12,13 +17,23 @@ image : compile #cat boot.bin program.bin > exe.bin sudo dd if=boot.bin of=disk.img bs=512 count=1 conv=notrunc sudo dd if=program.bin of=disk.img bs=512 seek=1 count=2 conv=notrunc - sudo dd if=beep.bin of=disk.img bs=512 seek=3 count=1 conv=notrunc + sudo dd if=software.bin of=disk.img bs=512 seek=3 count=1 conv=notrunc + sudo dd if=food.bin of=disk.img bs=512 seek=4 count=1 conv=notrunc + sudo dd if=beep.bin of=disk.img bs=512 seek=5 count=1 conv=notrunc + sudo dd if=voice.bin of=disk.img bs=512 seek=6 count=1 conv=notrunc + sudo dd if=silence.bin of=disk.img bs=512 seek=7 count=1 conv=notrunc + sudo dd if=light.bin of=disk.img bs=512 seek=8 count=1 conv=notrunc flashusb : image sudo dd if=boot.bin of=/dev/sdb bs=512 count=1 sudo dd if=program.bin of=/dev/sdb bs=512 seek=1 count=2 - sudo dd if=beep.bin of=/dev/sdb bs=512 seek=3 count=1 + sudo dd if=software.bin of=/dev/sdb bs=512 seek=3 count=1 + sudo dd if=food.bin of=/dev/sdb bs=512 seek=4 count=1 + sudo dd if=beep.bin of=/dev/sdb bs=512 seek=5 count=1 + sudo dd if=voice.bin of=/dev/sdb bs=512 seek=6 count=1 + sudo dd if=silence.bin of=/dev/sdb bs=512 seek=7 count=1 + sudo dd if=light.bin of=/dev/sdb bs=512 seek=8 count=1 # sudo dd if=exe.bin of=/dev/sdb bs=512 count=4 diff --git a/README.md b/README.md index dbd557b..3c34000 100755 --- a/README.md +++ b/README.md @@ -34,3 +34,9 @@ https://blog.ghaiklor.com/how-to-implement-a-second-stage-boot-loader-80e75ae427 ###Boc drawing characters https://en.wikipedia.org/wiki/Box-drawing_character + +###Good Array Tutorial +https://www.cs.uaf.edu/2017/fall/cs301/lecture/09_15_strings_arrays.html + +###ASCII Table +https://theasciicode.com.ar/ascii-printable-characters/space-ascii-code-32.html diff --git a/beep.asm b/beep.asm index 6ecf832..81d65cf 100644 --- a/beep.asm +++ b/beep.asm @@ -1,4 +1,4 @@ -[org 0x2000] +[org 0x4000] start: mov [bootdev], dl @@ -35,11 +35,10 @@ int 15h ; jne .pause2 ; dec bx ; jne .pause1 -; in al, 61h ; Turn off note (get value from -; ; port 61h). -; and al, 11111100b ; Reset bits 1 and 0. -; out 61h, al ; Send new value. -jmp exit + in al, 61h ; Turn off note (get value from + ; port 61h). + and al, 11111100b ; Reset bits 1 and 0. + out 61h, al ; Send new value. waitforkey: @@ -55,7 +54,7 @@ exit: and al, 11111100b ; Reset bits 1 and 0. out 61h, al ; Send new value. mov dl, [bootdev] - jmp 0x1000 + jmp 0x0:0x1000 bootdev db 0x80 ; Boot device number diff --git a/beep.bin b/beep.bin index ba639101fd36dc257672b33968babbad58570d44..b0b585222fb97c3eb98855306aeb524368e52e8a 100644 GIT binary patch delta 44 vcmeYcWa$tKaG1!Vqxd9I<@ delta 38 tcmWIaX6X>~Qkcl1BmJ6t3&UBlhChrYOs~H_NmTjsEU^nH^>W+$1^^Mk5UBtF diff --git a/boot.asm b/boot.asm index 52f32b7..48ff1ee 100755 --- a/boot.asm +++ b/boot.asm @@ -79,7 +79,7 @@ load_it_all_1: mov bx, 0x1000 ; BX = 0x1000. ES:BX=0x0:0x1000 ; ES:BX = starting address to read sector(s) into mov ah, 02 ; Int 13h/AH=2 = Read Sectors From Drive - mov al, 0x10 ; Sectors to read = 1 + mov al, 0x02 ; Sectors to read = 1 mov ch, 00 ; CH=Cylinder. Second sector of disk ; is at Cylinder 0 not 1 mov cl, 02 ; Sector to read = 2 diff --git a/boot.bin b/boot.bin index e8c72668a38a36949ba770dce7b3ac6396bc3d76..7557ac5ae2e96977481499e519802eb75f16cc89 100644 GIT binary patch delta 12 Tc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QHIR2}kn*j>X%AUU%$ZU;xn# zU~z^L&gK^&@t67kcW8hlUZ(x;mfI#Y=O@rGVW8T+1G^a%wlHlF*vhbxWgA16*e;>7 z!bKc&Uor41Ffjc3vae0(1s}t{*^|4N)$9Edb5j-c6<2CzkhJuZpuNmh21iDKYXl>ttEle92 zw=!&F=o0%PbXK^Cb?*PizrO4{AoPNdVc*rs9*pYsjyb6n3Lv1b5Rji*l9{X!oS#-w zo>-L1;Fyz{oC=XjGcZVDaLh|j&B@Hp1S$>72TBz)c;zQ2LN&W*!ylOvlh>~oZWC($p;5xoe1K!|Hlf!YI~W*1bOTtNp@g&f1xWm5 z{{I~sAc>c0|GVY33C;NlG)x$%w(r1h28At58w9p8Y-HKS&?UA@=&W!N$J|#8yb25q zzrO5i6MDhNuy6L{E=Kiwzr@^B1$_nAip1Q4oYa!clAKh9{4|AAOD$J`Xhcz90y4HNwWu;b53Ioy$PdfUOinFE wGROsJg&9a8#QtKi-5^I4Gvo_0fI&BuUIL|$Lg}ke`mNyR9HuF%q5lp literal 0 HcmV?d00001 diff --git a/software.asm b/software.asm new file mode 100644 index 0000000..9498fd0 --- /dev/null +++ b/software.asm @@ -0,0 +1,78 @@ +[org 0x2000] + +start: + mov [bootdev], dl + mov al, 182 ; meaning that we're about to load + out 43h, al ; prepare speaker for output + + mov ax, 2153 ; frequency countdown value is stored in ax. It is calculated by + out 42h, al ; Output low byte. + mov al, ah ; Output high byte. + out 42h, al + + in al, 61h + or al, 00000011b + out 61h, al ; Send the new value + +mov al, 0 +mov ah, 86h +mov cx, 1 +mov dx, 200 +int 15h + in al, 61h ; Turn off note (get value from + ; port 61h). + and al, 11111100b ; Reset bits 1 and 0. + out 61h, al ; Send new value. + + + mov ah, 06h ; Scroll up function + xor al, al ; Clear entire screen + xor cx, cx ; Upper left corner CH=row, CL=column + mov dx, 184FH ; lower right corner DH=row, DL=column + mov bh, 9Bh ; YellowOnBlue + int 10H ; execute interrupt + + mov ah, 02h ;sets cursor to top to write + mov bh, 0h + mov dh, 2h + mov dl, 2h + int 10h + mov si, description + call print + jmp waitforkey + +print: + lodsb + or al,al + jz .exit + mov ah,0x0e + int 10h + jmp print + .exit: + ret + +waitforkey: + mov ah, 0x00 + int 0x16 + cmp ah, 01h + je exit + jmp waitforkey + +exit: + in al, 61h ; Turn off note (get value from + ; port 61h). + and al, 11111100b ; Reset bits 1 and 0. + out 61h, al ; Send new value. + mov dl, [bootdev] + jmp 0x0:0x1000 + +description db "Poetic Software is a project .... . . . .",0 + +bootdev db 0x80 ; Boot device number + +%assign usedMemory ($-$$) +%assign usableMemory (512*16) +%warning [usedMemory/usableMemory] Bytes used +times (512*16)-($-$$) db 0 ;kernel must have size multiple of 512 so le$ + + diff --git a/software.bin b/software.bin new file mode 100644 index 0000000000000000000000000000000000000000..67e34dfe54f12a2f784a7f50beb96936042d2660 GIT binary patch literal 8192 zcmeIuI|{-;7zE(o6~rP)8pU!8Ytbvj11NZcB}9mYk+@)+N`fa4yn;oL#YYMeY_!-r zScFAPoz6l*58wf2rXB{qxUu5N&h!p`)j09pIGM1@MkJ&b#}cJi()CQVUPh=&=iI%e z{pNnHZN>JqV_T-}(}X`5<<_QpmK9agc3xZ*=|=P_NtPGi?ecT-B%5duc+z+IFc`_X z2tDr4xZu+;7<;bd?N9ix6cGXe2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa O0SG_<0uX?}zXETB@IQC} literal 0 HcmV?d00001 diff --git a/voice.asm b/voice.asm new file mode 100644 index 0000000..e56a92b --- /dev/null +++ b/voice.asm @@ -0,0 +1,60 @@ +[org 0x5000] + +start: + mov [bootdev], dl + mov ah, 06h ; Scroll up function + xor al, al ; Clear entire screen + xor cx, cx ; Upper left corner CH=row, CL=column + mov dx, 184FH ; lower right corner DH=row, DL=column + mov bh, 4Fh ; YellowOnBlue + int 10H ; execute interrupt + + mov al, 182 ; meaning that we're about to load + out 43h, al ; prepare speaker for output + + mov ax, 2153 ; frequency countdown value is stored in ax. It is calculated by + out 42h, al ; Output low byte. + mov al, ah ; Output high byte. + out 42h, al + + in al, 61h + or al, 00000011b + out 61h, al ; Send the new value +; mov bx, 200 ; Pause for duration of note. + +mov al, 0 +mov ah, 86h +mov cx, 1 +mov dx, 200 +int 15h + +;.pause1: +; mov cx, 65535 +;.pause2: +; dec cx +; jne .pause2 +; dec bx +; jne .pause1 + in al, 61h ; Turn off note (get value from + ; port 61h). + and al, 11111100b ; Reset bits 1 and 0. + out 61h, al ; Send new value. + + +waitforkey: + mov ah, 0x00 + int 0x16 + cmp ah, 01h + je exit + jmp waitforkey + +exit: + in al, 61h ; Turn off note (get value from + ; port 61h). + and al, 11111100b ; Reset bits 1 and 0. + out 61h, al ; Send new value. + mov dl, [bootdev] + jmp 0x0:0x1000 + +bootdev db 0x80 ; Boot device number + diff --git a/voice.bin b/voice.bin new file mode 100644 index 0000000000000000000000000000000000000000..7da6452389bf1f9377752c52d61d4c35ae57d7da GIT binary patch literal 81 zcmeAW3kcZ4W^lmp