Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Small issue with resolution of optional labels. #183

Open
hach-que opened this issue Oct 31, 2012 · 0 comments
Open

Small issue with resolution of optional labels. #183

hach-que opened this issue Oct 31, 2012 · 0 comments

Comments

@hach-que
Copy link
Member

test.c:

int main()
{
    return 0;
}

Run these commands:

dtcc/dtcc test.c -o test.dasm16
dtasm/dtasm test.dasm16 -o test.dobj16 -i
dtld/dtld -j kernel/stubsys.djmp16 -k kernel/stubsys.dkrn16 stdlib-c/stdlib.dlib16 test.dobj16 -o test.dcpu16
dtdb/dtdb test.dcpu16 -c "disasm 0x0 0x2F"

Output from dtdb will be:

Created VM.
hw:0:12d0b402:0:0
Loaded 0x0BFA words from test.dcpu16.
Flashed memory.
0x0000 (0x7F81):  >>> SET PC, 0x001F
0x0002 (0x00E9):      MDI J, A
0x0003 (0x00EC):      XOR J, A
0x0004 (0x00EF):      SHL J, A
0x0005 (0x00F1):      IFC J, A
0x0006 (0x0301):      SET PUSH, A
0x0007 (0x0701):      SET PUSH, B
0x0008 (0x84C1):      SET I, 0x0000
0x0009 (0x80D2):      IFE I, 0xFFFFFFFF
0x000A (0xEF81):      SET PC, 0x001A
0x000B (0x6CE1):      SET J, SP
0x000C (0x1A20):      HWQ [B+0x0000], I
0x000D (0x3C13):      IFN A, [J]
0x000E (0xE381):      SET PC, 0x0017
0x000F (0x5C32):      IFE B, [J+0x0001]
0x0011 (0xF781):      SET PC, 0x001C
0x0012 (0xE381):      SET PC, 0x0017
0x0013 (0x88C2):      ADD I, 0x0001
0x0014 (0xBB81):      SET PC, 0x000D
0x0015 (0x8401):      SET A, 0x0000
0x0016 (0x6381):      SET PC, POP
0x0017 (0x8F62):      ADD SP, 0x0002
0x0018 (0x1801):      SET A, I
0x0019 (0x6381):      SET PC, POP
0x001A (0x7C20):      JSR B, 0x0038
0x001C (0x7C01):      SET A, 0x7349
0x001E (0x7C21):      SET B, 0xF615
0x0020 (0x9C20):      JSR B, 0x0006
0x0021 (0x0301):      SET PUSH, A
0x0022 (0x8401):      SET A, 0x0000
0x0023 (0x7C21):      SET B, 0x8000
0x0025 (0x6240):      HWI [C+0x0000], POP
0x0026 (0x87F2):      IFE 0x0BF9, 0x0000
0x0028 (0x7C20):      JSR B, 0x00B8
0x002A (0x87F3):      IFN 0x0BF9, 0x0000
0x002C (0x8420):      JSR B, 0x0000
0x002D (0x7F81):      SET PC, 0x0033

Issue is instructions 0x2A -> 0x2C. If you look at the kernel/stubsys/start.dasm16, you can see that it's successfully replacing _start in the IFN instruction, but it doesn't do it for the JSR (which jumps to 0x0!)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant