From 6d3bb79970d4266631cff798e84ebdec904b23a1 Mon Sep 17 00:00:00 2001 From: sarkiroka Date: Sat, 24 Apr 2021 20:57:27 +0200 Subject: [PATCH 1/2] add big letscode text --- 512-byte-vm.asm | 88 +++++++++++++++++++++++++++++++++++------------- 512-byte-vm.raw | Bin 512 -> 512 bytes 2 files changed, 65 insertions(+), 23 deletions(-) diff --git a/512-byte-vm.asm b/512-byte-vm.asm index a43dda8..f157453 100644 --- a/512-byte-vm.asm +++ b/512-byte-vm.asm @@ -1,28 +1,70 @@ ORG 0x7C00 ; Starting address of the boot loader. BIOS expects it to be here. BITS 16 ; Start program in 16 bit mode. This is the default mode when the CPU starts. -main: - MOV SI, text_hello_world ; Move pointer to the text label into the SI register - CALL printText - JMP halt - -; printText prints a null-terminated string from the address passed in SI using the BIOS facility -printText: - MOV AH, 0x0E ; Set BIOS / INT 10 printing facility to text output -.printChar: - LODSB ; Load byte from the address in SI into AL and advance SI by one - OR AL, AL ; Equal to CMP AL, 0, but shorter in byte code - JE .printReturn ; If yes, jump to the return - INT 0x10 ; Trigger BIOS print method - JMP .printChar ; Repeat for next byte -.printReturn: - RET ; Return from the printText function - -halt: - HLT ; Halt CPU if the APM shutdown failed. - -text_hello_world: - DB "Hello World!", 13, 0 ; Embed data into binary, zero-terminated. + MOV BP, characters + MOV SI, encoded_text + XOR DX,DX +print_next_character: + LODSB ; next encoded data + MOV DL,AL ; save the "address" + AND DL,0F0h ; remove the "count" part + SHR DL,4 ; normalize it + MOV DI,DX ; it doesn't understand effective address with DX, so move to DI + MOV CL,AL ; save the "count" part + AND CL,0Fh ; remove the "address" part + CMP CL,0 ; is it the end? when count==0 that mean the end + JZ end_of_print ; yes, this is the end of encoded data + CMP CL,0Fh ; is it special character? when count==15 that mean special non-compressed character + JNZ continue_to_compressed_text ; no, continue with compressed character + LODSB ; yes, it not compressed, load next byte + MOV CL,1 ; the count is always 1 for special characters + JMP print_again ; go to print +continue_to_compressed_text: + MOV AL,[BP+DI] ; load the "real" character +print_again: + MOV AH,0Eh ; teletype mode + MOV BX,7 ; lightgray character on black background + INT 10h ; call the print BIOS service + DEC CL ; calculate how many character remain + JNZ print_again ; if has more, then print it again + JMP print_next_character ; else print next character + + +end_of_print: + XOR AH,AH ; wait a keyboard press + INT 16h ; call BIOS service + +shutdown: + MOV AX,0x1000 ; fallback segment + MOV SS,AX ; store into stacksegment + MOV SP,0f000h ; fallback offset + MOV AX,5307h ; call apm service: set power state + MOV BX,1 ; to all device + MOV CX,3 ; power off + INT 15h ; call BIOS service (apm) + RET ; fallback when apm failed - direct jump into reboot address + +characters: ; the real characters: "█k╚r╗s║╔═╝ ao--" + ; indexes 0123456789abcde + DB 219,107,200,114,187,115,186,201,205,188,32,97,111,10,13 + +encoded_text: + DB 0d1h,0e1h + ; L E T S C O D E + DB 02h,41h,0a5h, 07h,41h, 08h,41h, 07h,41h,0a5h, 06h,41h,0a1h, 06h,41h,0a1h, 06h,41h,0a1h, 07h,41h,0d1h,0e1h + DB 02h,61h,0a5h, 02h,71h,84h,91h, 21h,82h,02h,71h,82h,91h, 02h,71h,84h,91h,0a4h, 02h,71h,84h,91h, 02h,71h,83h,02h,41h, 02h,71h,82h,02h,41h, 02h,71h,84h,91h,0d1h,0e1h + DB 02h,61h,0a5h, 05h,41h,0a5h, 02h,61h,0a3h, 07h,41h,0a4h, 02h,61h,0a5h, 02h,61h,0a3h,02h,61h, 02h,61h,0a2h,02h,61h, 05h,41h,0d1h,0e1h + DB 02h,61h,0a5h, 02h,71h,82h,91h,0a5h, 02h,61h,0a3h, 21h,84h,02h,61h,0a4h, 02h,61h,0a5h, 02h,61h,0a3h,02h,61h, 02h,61h,0a2h,02h,61h, 02h,71h,82h,91h,0d1h,0e1h + DB 07h,41h, 07h,41h,0a3h, 02h,61h,0a3h, 07h,61h,0a4h, 21h,06h,41h, 21h,06h,71h,91h, 06h,71h,91h, 07h,41h,0d1h,0e1h + DB 21h,86h,91h, 21h,86h,91h,0a3h, 21h,81h,91h,0a3h, 21h,86h,91h,0a5h, 21h,85h,91h,0a1h, 21h,85h,91h,0a1h, 21h,85h,91h,0a1h, 21h,86h,91h,0d1h,0e1h + DB 0aeh,0aeh,0aeh,0aeh,0a6h,0fh,6ah,0b1h,0fh,6eh,0c1h,51h,0fh,7ah,0fh,65h,0fh,6eh,0d1h,0e1h + DB 0aeh,0aeh,0aeh,0aeh,0a5h,51h,0b1h,31h,11h,0fh,69h,31h,0c1h,11h,0b1h,0d1h,0e1h + DB 0d1h,0e1h,0fh,07h + + DB 0fh,48h,0fh,65h,0fh,6ch,0fh,6ch,0c1h,0a1h,0fh,57h,0c1h,31h,0fh,6ch,0fh,64h,0a1h, 0fh,69h,51h,0a1h, 0c1h,11h,0fh,2eh,0fh,2eh,0fh,2eh,0d1h,0e1h + + DB 0 ; end of encoded text + DB 90h,90h,90h,90h,90h,90h,90h TIMES 510 - ($ - $$) DB 0 ; Fill up 510 bytes -DW 0xAA55 ; Write magic bytes for boot loader \ No newline at end of file +DW 0xAA55 ; Write magic bytes for boot loader diff --git a/512-byte-vm.raw b/512-byte-vm.raw index 91a3a71f7f3a8b828c853f2e4bfd6dc529903b5f..01526d44727ec24507b15d57e29c4c941f45f866 100644 GIT binary patch literal 512 zcmdn%SF2k_|ukOIg=!WPHuk#k_@YH#@^w zfqy4UzrMa?@Z_x64hDg~3wszo>|hVx&B(Bmnc=MH;oI3Kigp+8I(c@FLSjA_@5P5q zj!W4cIULy?m$Er7gdlcDpm5?+roxtqicL&~O%p+^B_M*Su$jpbC;}o{CW2M5Ixb~O zT+Hsc1f(NzF;gN_;v%L*R+te@6G5ViEli213P8qQe8>*87pP@1d*TvBHb+Ia!ihix zvR<)mA`mTBYy{%AiAxn*CoY8JHlW6JK(LHIYa@T&!9e~h{#5=vh}hD=jfR5!nT7`i yH(q>r@gYAuzXwnNN?6Vcy#9Xpi$`isPQF5Teo;<}A}_-z7`7o0x(WbVIS-xy From fbf578851ffdabcf2f70120b2f9c1a95ae0c92d7 Mon Sep 17 00:00:00 2001 From: sarkiroka Date: Sun, 25 Apr 2021 23:09:14 +0200 Subject: [PATCH 2/2] fix art, to "oVirt" --- 512-byte-vm.asm | 23 ++++++++++++----------- 512-byte-vm.raw | Bin 512 -> 512 bytes test.sh | 3 +-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/512-byte-vm.asm b/512-byte-vm.asm index f157453..78ae601 100644 --- a/512-byte-vm.asm +++ b/512-byte-vm.asm @@ -50,21 +50,22 @@ characters: ; the real characters: "█k╚r╗s║╔═╝ ao--" encoded_text: DB 0d1h,0e1h - ; L E T S C O D E - DB 02h,41h,0a5h, 07h,41h, 08h,41h, 07h,41h,0a5h, 06h,41h,0a1h, 06h,41h,0a1h, 06h,41h,0a1h, 07h,41h,0d1h,0e1h - DB 02h,61h,0a5h, 02h,71h,84h,91h, 21h,82h,02h,71h,82h,91h, 02h,71h,84h,91h,0a4h, 02h,71h,84h,91h, 02h,71h,83h,02h,41h, 02h,71h,82h,02h,41h, 02h,71h,84h,91h,0d1h,0e1h - DB 02h,61h,0a5h, 05h,41h,0a5h, 02h,61h,0a3h, 07h,41h,0a4h, 02h,61h,0a5h, 02h,61h,0a3h,02h,61h, 02h,61h,0a2h,02h,61h, 05h,41h,0d1h,0e1h - DB 02h,61h,0a5h, 02h,71h,82h,91h,0a5h, 02h,61h,0a3h, 21h,84h,02h,61h,0a4h, 02h,61h,0a5h, 02h,61h,0a3h,02h,61h, 02h,61h,0a2h,02h,61h, 02h,71h,82h,91h,0d1h,0e1h - DB 07h,41h, 07h,41h,0a3h, 02h,61h,0a3h, 07h,61h,0a4h, 21h,06h,41h, 21h,06h,71h,91h, 06h,71h,91h, 07h,41h,0d1h,0e1h - DB 21h,86h,91h, 21h,86h,91h,0a3h, 21h,81h,91h,0a3h, 21h,86h,91h,0a5h, 21h,85h,91h,0a1h, 21h,85h,91h,0a1h, 21h,85h,91h,0a1h, 21h,86h,91h,0d1h,0e1h - DB 0aeh,0aeh,0aeh,0aeh,0a6h,0fh,6ah,0b1h,0fh,6eh,0c1h,51h,0fh,7ah,0fh,65h,0fh,6eh,0d1h,0e1h - DB 0aeh,0aeh,0aeh,0aeh,0a5h,51h,0b1h,31h,11h,0fh,69h,31h,0c1h,11h,0b1h,0d1h,0e1h - DB 0d1h,0e1h,0fh,07h + ; o V i r t + DB 0a9h, 02h,41h,0a5h,02h,41h, 02h,41h, 0aah, 02h,41h,0d1h,0e1h + DB 0a9h, 02h,61h,0a5h,02h,61h, 21h,81h,91h, 0a8h, 07h,41h,0d1h,0e1h + DB 0a1h,06h,41h,0a1h, 02h,61h,0a5h,02h,61h, 02h,41h, 02h,41h,04h,41h, 0a2h,02h,71h,82h,91h,0d1h,0e1h + DB 02h,71h,83h,02h,41h, 21h,02h,41h,0a3h,02h,71h,91h, 02h,61h, 04h,71h,81h,02h,41h, 0a1h,02h,61h,0d1h,0e1h + DB 02h,61h,0a3h,02h,61h, 0a1h,21h,02h,41h,0a1h,02h,71h,91h,0a1h, 02h,61h, 02h,71h,81h,91h,0a1h,21h,81h,91h, 0a1h,02h,61h,0a1h,02h,41h,0d1h,0e1h + DB 21h,06h,71h,91h, 0a2h,21h,04h,71h,91h,0a2h, 02h,61h, 02h,61h,0a7h, 21h,04h,71h,91h,0d1h,0e1h + DB 0a1h,21h,85h,91h,0a4h, 21h,83h,91h,0a3h, 21h,81h,91h, 21h,81h,91h,0a8h, 21h,83h,91h,0d1h,0e1h + + DB 0aeh,0aeh,0a4h,0fh,6ah,0b1h,0fh,6eh,0c1h,51h,0fh,7ah,0fh,65h,0fh,6eh,0d1h,0e1h + DB 0aeh,0aeh,0a3h,51h,0b1h,31h,11h,0fh,69h,31h,0c1h,11h,0b1h,0d1h,0e1h + DB 0d1h,0e1h,0d1h,0e1h,0fh,07h DB 0fh,48h,0fh,65h,0fh,6ch,0fh,6ch,0c1h,0a1h,0fh,57h,0c1h,31h,0fh,6ch,0fh,64h,0a1h, 0fh,69h,51h,0a1h, 0c1h,11h,0fh,2eh,0fh,2eh,0fh,2eh,0d1h,0e1h DB 0 ; end of encoded text - DB 90h,90h,90h,90h,90h,90h,90h TIMES 510 - ($ - $$) DB 0 ; Fill up 510 bytes DW 0xAA55 ; Write magic bytes for boot loader diff --git a/512-byte-vm.raw b/512-byte-vm.raw index 01526d44727ec24507b15d57e29c4c941f45f866..14ab8a1947e44e1e2a5a6ccc388b9d32471b68f4 100644 GIT binary patch delta 203 zcmW-au?@m76hxJi6-tW{+|i~$(0YUv)W`(|6p>6xLqbGHft3jyCxWDilo2w5NAM3Nb~# za!{6lB|r{zWh_;Zw6R;H+O&evA*Mc2(Zp6fO($yOC>eK2`Y=r$zs$T?a(?3{UPQ;` YbGGK^Y+27fH2Y-JT$5K*COaI)AK!9Le*gdg delta 244 zcmY*SF%E)25DXjO>@LI?TxZJ@_6Za=Hf9S8El6l>L_}&f6xMj0g@p-E;0Zi|pLi$H z#L4VrGnv`V{oJp&CqN@`fdWm4?M#8=1Y{s9Srw2K?6%GcWEVi|I4Sv)3eW&)ft_oR z1_HVR1>X||J6DxJ{{eS)oCIzJ+Kv{~sSs6|v8DU3Dz?<>Y^P$QuH62nvdx#pLmqmW f4v9R6 diff --git a/test.sh b/test.sh index bf0c7fb..cbe269d 100755 --- a/test.sh +++ b/test.sh @@ -36,8 +36,7 @@ echo 'screendump /tmp/screendump quit' | nc localhost 2000 >/dev/null sleep 1 echo "Performing OCR and evaluating results..." -# We skip the H here because the OCR might interpret the blinking cursor as an underscore instead of a H -if [ $(gocr -m 4 /tmp/screendump | grep 'ello World' | wc -l) -eq 1 ]; then +if [ $(gocr -m 4 /tmp/screendump | grep 'Hello World' | wc -l) -eq 1 ]; then echo -e "\033[0;32mTest successful\033[0m" exit 0 fi