Compare commits
2 Commits
df105ea3cf
...
85a8172923
Author | SHA1 | Date | |
---|---|---|---|
85a8172923 | |||
fafb440891 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@
|
||||
/decoder8086
|
||||
/performance-aware
|
||||
/sim8086
|
||||
/listing-*.data
|
||||
|
43
asm_files/list-0054.asm
Normal file
43
asm_files/list-0054.asm
Normal file
@ -0,0 +1,43 @@
|
||||
; ========================================================================
|
||||
;
|
||||
; (C) Copyright 2023 by Molly Rocket, Inc., All Rights Reserved.
|
||||
;
|
||||
; This software is provided 'as-is', without any express or implied
|
||||
; warranty. In no event will the authors be held liable for any damages
|
||||
; arising from the use of this software.
|
||||
;
|
||||
; Please see https://computerenhance.com for further information
|
||||
;
|
||||
; ========================================================================
|
||||
|
||||
; ========================================================================
|
||||
; LISTING 54
|
||||
; ========================================================================
|
||||
|
||||
bits 16
|
||||
|
||||
; Start image after one row, to avoid overwriting our code!
|
||||
mov bp, 64*4
|
||||
|
||||
mov dx, 0
|
||||
y_loop_start:
|
||||
|
||||
mov cx, 0
|
||||
x_loop_start:
|
||||
; Fill pixel
|
||||
mov word [bp + 0], cx ; Red
|
||||
mov word [bp + 2], dx ; Blue
|
||||
mov byte [bp + 3], 255 ; Alpha
|
||||
|
||||
; Advance pixel location
|
||||
add bp, 4
|
||||
|
||||
; Advance X coordinate and loop
|
||||
add cx, 1
|
||||
cmp cx, 64
|
||||
jnz x_loop_start
|
||||
|
||||
; Advance Y coordinate and loop
|
||||
add dx, 1
|
||||
cmp dx, 64
|
||||
jnz y_loop_start
|
28938
asm_files/list-0054.txt
Normal file
28938
asm_files/list-0054.txt
Normal file
File diff suppressed because it is too large
Load Diff
53
asm_files/list-0055.asm
Normal file
53
asm_files/list-0055.asm
Normal file
@ -0,0 +1,53 @@
|
||||
; ========================================================================
|
||||
;
|
||||
; (C) Copyright 2023 by Molly Rocket, Inc., All Rights Reserved.
|
||||
;
|
||||
; This software is provided 'as-is', without any express or implied
|
||||
; warranty. In no event will the authors be held liable for any damages
|
||||
; arising from the use of this software.
|
||||
;
|
||||
; Please see https://computerenhance.com for further information
|
||||
;
|
||||
; ========================================================================
|
||||
|
||||
; ========================================================================
|
||||
; LISTING 55
|
||||
; ========================================================================
|
||||
|
||||
bits 16
|
||||
|
||||
; Start image after one row, to avoid overwriting our code!
|
||||
mov bp, 64*4
|
||||
|
||||
; Draw the solid rectangle red/blue/alpha
|
||||
mov dx, 64
|
||||
y_loop_start:
|
||||
|
||||
mov cx, 64
|
||||
x_loop_start:
|
||||
mov byte [bp + 0], cl ; Red
|
||||
mov byte [bp + 1], 0 ; Green
|
||||
mov byte [bp + 2], dl ; Blue
|
||||
mov byte [bp + 3], 255 ; Alpha
|
||||
add bp, 4
|
||||
|
||||
loop x_loop_start
|
||||
|
||||
sub dx, 1
|
||||
jnz y_loop_start
|
||||
|
||||
; Add the line rectangle green
|
||||
mov bp, 64*4 + 4*64 + 4
|
||||
mov bx, bp
|
||||
mov cx, 62
|
||||
outline_loop_start:
|
||||
|
||||
mov byte [bp + 1], 255 ; Top line
|
||||
mov byte [bp + 61*64*4 + 1], 255 ; Bottom line
|
||||
mov byte [bx + 1], 255 ; Left line
|
||||
mov byte [bx + 61*4 + 1], 255 ; Right line
|
||||
|
||||
add bp, 4
|
||||
add bx, 4*64
|
||||
|
||||
loop outline_loop_start
|
25214
asm_files/list-0055.txt
Normal file
25214
asm_files/list-0055.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -111,6 +111,9 @@ execute_instruction :: proc(cpu: ^Cpu, inst: Instruction) {
|
||||
case .JP, .JPE: jump = cpu.flags[.PF]
|
||||
case .JB, .JNAE: jump = cpu.flags[.CF]
|
||||
|
||||
case .LOOP:
|
||||
cpu.registers[.cx].full -= 1
|
||||
jump = cpu.registers[.cx].full != 0
|
||||
case .LOOPNZ, .LOOPNE:
|
||||
cpu.registers[.cx].full -= 1
|
||||
// According to this resource, the loopnz inst does not change any flags
|
||||
|
14
sim8086.odin
14
sim8086.odin
@ -95,4 +95,18 @@ main :: proc() {
|
||||
if what_to_print == "instructions" || what_to_print == "all" {
|
||||
print_instructions_stdout(instructions_list[:])
|
||||
}
|
||||
if len(os.args) > 3 && os.args[3] == "dump" {
|
||||
f2,open_err := os.open("./listing-54.data", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
|
||||
if open_err == nil {
|
||||
bytes_written,write_err := os.write(f2, cpu.memory[:])
|
||||
if write_err == nil {
|
||||
fmt.println("Dumpped", bytes_written, "to disk: listing-54.data")
|
||||
} else {
|
||||
fmt.println("Error2:", write_err)
|
||||
}
|
||||
} else {
|
||||
fmt.println("Error1:", open_err)
|
||||
}
|
||||
defer os.close(f)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user