NAME=load 16 bits omf
FILE=bins/omf/hello_world
CMDS=iI~bits
EXPECT=<<EOF
bits     16
EOF
RUN

NAME=entry point 16 bits omf
FILE=bins/omf/hello_world
CMDS=ie~addr
EXPECT=<<EOF
vaddr=0x00001000 paddr=0x00000073 haddr=-1 type=program
EOF
RUN

NAME=symbols 16 bits omf
FILE=bins/omf/hello_world
CMDS=is
EXPECT=<<EOF
[Symbols]

nth paddr       vaddr      bind type size lib name
--------------------------------------------------
1    0x00000073 0x00001000 NONE NONE 0        _start
EOF
RUN

NAME=sections 16 bits omf
FILE=bins/omf/hello_world
CMDS=iS
EXPECT=<<EOF
[Sections]

nth paddr       size vaddr       vsize perm name
------------------------------------------------
0   0x00000073  0x13 0x00001000   0x13 -rwx text_1
1   0x00000095   0xe 0x00001013    0xe -rwx data_1

EOF
RUN

NAME=sections 16 bits omf - content
FILE=bins/omf/hello_world
CMDS=px 16 @ section.text_1; px 16 @ section.data_1
EXPECT=<<EOF
- offset -  0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
0000:1000  ba0e 00b9 0000 bb01 00b8 0400 cd80 b801  ................
- offset -  0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
0000:1013  4865 6c6c 6f2c 2077 6f72 6c64 210a ffff  Hello, world!...
EOF
RUN

NAME=virtual address 16 bits omf
FILE=bins/omf/hello_world
CMDS=e asm.bytes=true;pid 1~mov[1];
EXPECT=<<EOF
ba0e00
EOF
RUN

NAME=load 32 bits omf
FILE=bins/omf/hello_world32
CMDS=e asm.bytes=true; iI~bits;
EXPECT=<<EOF
bits     32
EOF
RUN

NAME=entry point 32 bits omf
FILE=bins/omf/hello_world32
CMDS=ie~addr
EXPECT=<<EOF
vaddr=0x00001000 paddr=0x00000074 haddr=-1 type=program
EOF
RUN

NAME=symbols 32 bits omf
FILE=bins/omf/hello_world32
CMDS=is
EXPECT=<<EOF
[Symbols]

nth paddr       vaddr      bind type size lib name
--------------------------------------------------
1    0x00000074 0x00001000 NONE NONE 0        _start
EOF
RUN

NAME=sections 32 bits omf
FILE=bins/omf/hello_world32
CMDS=iS
EXPECT=<<EOF
[Sections]

nth paddr       size vaddr       vsize perm name
------------------------------------------------
0   0x00000074  0x1d 0x00001000   0x1d -rwx .text_1
1   0x000000a3   0xe 0x0000101d    0xe -rwx .data_1

EOF
RUN

NAME=virtual address 32 bits omf
FILE=bins/omf/hello_world32
CMDS=e asm.bytes=true; pid 1~mov[1]
EXPECT=<<EOF
ba0e000000
EOF
RUN

NAME=multiple symbols omf
FILE=bins/omf/multi_pubdef
CMDS=is
EXPECT=<<EOF
[Symbols]

nth paddr       vaddr      bind type size lib name
--------------------------------------------------
1    0x00000084 0x00001000 NONE NONE 0        _start
2    0x00000097 0x00001013 NONE NONE 0        second_symbol
EOF
RUN

NAME=null checksum omf
FILE=bins/omf/null_checks
CMDS=is
EXPECT=<<EOF
[Symbols]

nth paddr       vaddr      bind type size lib name
--------------------------------------------------
1    0x00000073 0x00001000 NONE NONE 0        _start
EOF
RUN

NAME=invalide index segment omf
FILE=bins/omf/invalid_idx
CMDS=q!
EXPECT=<<EOF
EOF
RUN

NAME=invalide string size pubdef record omf
FILE=bins/omf/invalid_str_pubdef
CMDS=q!
EXPECT=<<EOF
EOF
RUN

NAME=invalide string size lnames record omf
FILE=bins/omf/invalid_str_lname
CMDS=q!
EXPECT=<<EOF
EOF
RUN

NAME=invalide record size omf
FILE=bins/omf/invalid_size
CMDS=q!
EXPECT=<<EOF
EOF
RUN
