Skip to content

Instantly share code, notes, and snippets.

@piotrwyrw
Last active September 28, 2022 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrwyrw/9845eec605a19de1e86d7ed8a1f10319 to your computer and use it in GitHub Desktop.
Save piotrwyrw/9845eec605a19de1e86d7ed8a1f10319 to your computer and use it in GitHub Desktop.
Bug report source code
[org 0x7C00]
[bits 16]
%macro tty 1
mov si, %1
call Print
%endmacro
;; Clear the segment registers
xor ax, ax
mov ds, ax
mov ss, ax
mov bp, ss
mov sp, bp
mov gs, ax
mov fs, ax
mov es, ax
;; Far jump
jmp 0:Start
Start:
call VideoMode
tty MESSAGE
jmp $
nop
VideoMode:
mov ah, 0x0
mov al, 0x2
int 0x10
ret
nop
Print:
jmp .char
.endl:
mov ah, 0x3
mov bh, 0x0
int 0x10
;; dh = row (y)
;; dl = column (x)
xor dl, dl
inc dh
mov ah, 0x2
mov bh, 0x0
int 0x10
.char:
lodsb ;; Load the [al] register with the next
;; byte/character from the string
cmp al, 0x0
je .end
cmp al, 0x10
je .endl
mov ah, 0xE
mov bh, 0x0
int 0x10
jmp .char
.end:
ret
MESSAGE: db "Hello, World!", 0x10, 0x0
;; Boot signature
times 510 - ($ - $$) db 0
dw 0xAA55
[org 0x7C00]
[bits 16]
%macro tty 1
mov si, %1
call Print
%endmacro
;; Clear the segment registers
xor ax, ax
mov ds, ax
mov ss, ax
mov bp, ss
mov sp, bp
mov gs, ax
mov fs, ax
mov es, ax
;; Far jump
jmp 0:Start
Start:
call VideoMode
tty MESSAGE
jmp $
nop
VideoMode:
mov ah, 0x0 ;; \
mov al, 0x2 ;; | Change the video mode to 80x25 text
int 0x10 ;; /
ret
nop
Print:
jmp .char
.endl:
mov ah, 0x3 ;; \
mov bh, 0x0 ;; | Get the cursor position
int 0x10 ;; /
;; dh = row (y)
;; dl = column (x)
xor dl, dl
inc dh
mov ah, 0x2 ;; \
mov bh, 0x0 ;; | Set the new cursor position
int 0x10 ;; /
.char:
lodsb ;; Load the [al] register with the next
;; byte/character from the string
cmp al, 0x0 ;; \ Check if the current character is
je .end ;; / a null terminator
cmp al, 0x10 ;; \ Check for a newline character
je .endl ;; /
mov ah, 0xE ;; \
mov bh, 0x0 ;; | Teletype output
int 0x10 ;; /
jmp .char
.end:
ret
MESSAGE: db "Hello, World!", 0x10, 0x0
;; Boot signature
times 510 - ($ - $$) db 0
dw 0xAA55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment