finish day 1

This commit is contained in:
sangge-redmi 2024-01-16 23:34:00 +08:00
parent 845aa1c6b6
commit dda87f83cd
5 changed files with 47 additions and 0 deletions

22
day_01/append_helloos.py Normal file
View File

@ -0,0 +1,22 @@
"""
This script is used to attach zero bytes to img file
REMENBER TO CHECK 0x01FF AND 0x1400
"""
def append_zeros_to_bin_file(file_path, target_size_hex):
target_size = int(target_size_hex, 16) # Convert hex size to decimal
with open(file_path, "ab") as file: # Open the file in append binary mode
file.seek(0, 2) # Go to the end of the file
current_size = file.tell() # Get the current size of the file
zeros_to_add = (
target_size - current_size
) # Calculate the number of zeros to add
if zeros_to_add > 0:
file.write(b"\x00" * zeros_to_add) # Append the zeros
else:
print("File is already at or exceeds the target size.")
# Usage
append_zeros_to_bin_file("helloos.img", "0x168000")

BIN
day_01/asm_result.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 KiB

25
day_01/helloos.asm Normal file
View File

@ -0,0 +1,25 @@
; Hello World Program in 16-bit Assembly
; This code is intended to run on a DOS system.
.model small
.stack 100h
.data
helloMessage db 'Hello, World!$'
.code
start:
; Initialize the data segment
mov ax, @data
mov ds, ax
; Display the message
mov ah, 09h ; AH = 09h for displaying a string in DOS
lea dx, helloMessage ; Load the address of the message into DX
int 21h ; Call DOS interrupt
; Terminate the program
mov ax, 4C00h ; Terminate program
int 21h
end start

BIN
day_01/helloos.img Normal file

Binary file not shown.

BIN
day_01/result.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB