Browse Source

Dump status flags

special_first_anniversary_edition
Jakob Kjær-Kammersgaard 5 years ago
parent
commit
e158cafac4
5 changed files with 68 additions and 6 deletions
  1. +4
    -1
      .gitignore
  2. BIN
      SingOS.img
  3. BIN
      kernel.bin
  4. +5
    -0
      kernel.nasm
  5. +59
    -5
      lib/debug_tools.nasm

+ 4
- 1
.gitignore View File

@ -1,2 +1,5 @@
.DS_Store
*.sublime*
*.swp
*.sublime*
*.img
*.bin

BIN
SingOS.img View File


BIN
kernel.bin View File


+ 5
- 0
kernel.nasm View File

@ -21,6 +21,11 @@ start_sing:
call dump_general_registers
call printCRLF
call printCRLF
; mov dx, ('N'<<8)|'T'
; call dump_dx_as_two_chars
call dump_status_flags
mov si, command_line
call print
jmp terminal

+ 59
- 5
lib/debug_tools.nasm View File

@ -125,14 +125,14 @@ keyprint:
dump_stack_registers:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
push si
lea si, [.string_1]
lea si, [.string_sp]
call print
push ax
mov ax, sp
call dumpax
lea si, [.string_2]
lea si, [.string_bp]
call print
mov ax, bp
@ -141,8 +141,8 @@ dump_stack_registers:
pop si
ret
.string_1: db 13, 10, "SP:", 0
.string_2: db ", BP:", 0
.string_sp: db 13, 10, "SP:", 0
.string_bp: db ", BP:", 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dump_general_registers:
@ -187,4 +187,58 @@ dump_general_registers:
.string_dx: db 13, 10, "DX:",0
.string_bx: db ", BX:",0
.string_si: db 13, 10, "SI:",0
.string_di: db ", DI:",0
.string_di: db ", DI:",0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dump_dx_as_two_chars:
; IN dh: first char
; IN dl: second char
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
push ax
mov ah, 0xE
mov al, dh
int 0x10
mov al, dl
int 0x10
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dump_status_flags:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pushf
push ax
push dx
; Move flags into ah
lahf
mov al, ah
test al, (1<<7) ; Sign flag
jz .S1
mov dx, ('S'<<8)|'f'
call dump_dx_as_two_chars
.S1:
test al, (1<<6) ; Zero flag
jz .S2
mov dx, ('Z'<<8)|'f'
call dump_dx_as_two_chars
.S2:
test al, (1<<4) ; Adjust flag
jz .S3
mov dx, ('A'<<8)|'f'
call dump_dx_as_two_chars
.S3:
test al, (1<<2) ; Parity flag
jz .S4
mov dx, ('P'<<8)|'f'
call dump_dx_as_two_chars
.S4:
test al, (1<<0) ; Carry flag
jz .S5
mov dx, ('C'<<8)|'f'
call dump_dx_as_two_chars
.S5:
pop dx
pop ax
popf
ret

Loading…
Cancel
Save