Skip to content

Commit

Permalink
[Python][Disasm] Emit org directive.
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Aug 17, 2024
1 parent e2f3f35 commit dcd3b0c
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/disasm/bytes-with_comments.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
db 0xf3 ; @@ 0x0000 f3
db 0xaf ; @@ 0x0001 af 11 Hey.
---
org 0x0
db 0xf3 ; @@ 0x0000 f3
db 0xaf ; @@ 0x0001 af Hey.
db 0x11 ; @@ 0x0002 11
1 change: 1 addition & 0 deletions tests/disasm/bytes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
db 0xaf ; @@ 0x0001 af Hey.
db 0x11 ; @@ 0x0002 11
---
org 0x0
db 0xf3 ; @@ 0x0000 f3
db 0xaf ; @@ 0x0001 af Hey.
db 0x11 ; @@ 0x0002 11
1 change: 1 addition & 0 deletions tests/disasm/call.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

ld hl, 0x0 ; @@ 0x0daf 21 00 00
---
org 0xd6b
call 0xdaf ; @@ 0x0d6b cd af 0d .instr
ld hl, 0x5c3c ; @@ 0x0d6e 21 3c 5c
.space 62
Expand Down
1 change: 1 addition & 0 deletions tests/disasm/comment.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
; @@ 0x0000 : Hello
; @@ 0x0000 : World
---
org 0x0
; @@ 0x0000 : Hello
; @@ 0x0000 : World
1 change: 1 addition & 0 deletions tests/disasm/include_binary-no_comment.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@@ 0x0000 .include_binary 'input.bin'

---
org 0x0
; @@ 0x0000 Included from binary file 'input.bin'.
db 0xf3, 0xaf, 0x11, 0xff ; @@ 0x0000 f3 af 11 ff
db 0xff, 0xc3, 0xcb, 0x11 ; @@ 0x0004 ff c3 cb 11
1 change: 1 addition & 0 deletions tests/disasm/include_binary.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@@ 0x0000 .include_binary 'input.bin' -- The source binary.

---
org 0x0
; @@ 0x0000 Included from binary file 'input.bin'.
; @@ 0x0000 The source binary.
db 0xf3, 0xaf, 0x11, 0xff ; @@ 0x0000 f3 af 11 ff
Expand Down
1 change: 1 addition & 0 deletions tests/disasm/index_regs.asm
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org 0x1230
ld iy, 0x5c3a ; @@ 0x1230 fd 21 3a 5c .instr
1 change: 1 addition & 0 deletions tests/disasm/instr.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
; @@ 0x0000 0xf3 .instr -- Hey.
; @@ 0x0001 0xaf
---
org 0x0
di ; @@ 0x0000 f3 .instr -- Hey.
xor a ; @@ 0x0001 af
1 change: 1 addition & 0 deletions tests/disasm/overlapping_instr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

jr 0x2734 ; @@ 0x2771 18 c1 .instr
---
org 0x2756
rst 0x28 ; @@ 0x2756 ef .instr
dec sp ; @@ 0x2757 3b
jr c, 0x2772 ; @@ 0x2758 38 18
Expand Down
1 change: 1 addition & 0 deletions tests/disasm/relative_jump.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
org 0x11dc
ld (hl), 0x2 ; @@ 0x11dc 36 02 .instr
dec hl ; @@ 0x11de 2b
cp h ; @@ 0x11df bc
Expand Down
1 change: 1 addition & 0 deletions tests/disasm/ret-conditional.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
org 0xc32
cp 0x82 ; @@ 0x0c32 fe 82 .instr
ret c ; @@ 0x0c34 d8
ld a, d ; @@ 0x0c35 7a
1 change: 1 addition & 0 deletions tests/disasm/ret.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
org 0x16d2
pop hl ; @@ 0x16d2 e1 .instr
ret ; @@ 0x16d3 c9
db 0xed ; @@ 0x16d4 ed
1 change: 1 addition & 0 deletions z80/_disasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ def __get_asm_lines(self):
for a in sorted(a for a, t in self.__tags.items() if not t.empty):
if addr is None:
addr = a
yield _AsmLine(command='org 0x%x' % addr)
elif a < addr:
continue
elif a > addr:
Expand Down

0 comments on commit dcd3b0c

Please sign in to comment.