asm.bi 1.5 KB
Newer Older
1 2 3 4
'
' asm.bi
'
common shared asm_offset as ushort
5
common shared dasm_offset as ushort
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

#define O_MASK &H80
#define AMOD_MASK &H78
#define DISP_MASK &H7

type t_operand
    amod as ubyte
    low_byte as ubyte
    high_byte as ubyte
    byte_count as ubyte
    displacement as ubyte
    register as ubyte
    memory as ubyte
    immediate as ubyte
    has_displacement as ubyte
    indirect as ubyte
John P. Willis's avatar
John P. Willis committed
22 23

    data_type as ubyte ' 0 = byte, 1 = word
24 25
end type

John P. Willis's avatar
John P. Willis committed
26
declare function asm_encode_amod(data_type as ubyte, amod as ubyte, disp as ubyte) as ubyte
John P. Willis's avatar
John P. Willis committed
27
declare function asm_amod_datatype(amod as ubyte) as ubyte
28 29 30
declare function asm_amod_amod(amod as ubyte) as ubyte
declare function asm_amod_disp(amod as ubyte) as ubyte
declare function asm_decode_disp(disp as ubyte) as ushort
John P. Willis's avatar
John P. Willis committed
31
declare function asm_encode_address(data_type as ubyte, addr_string as string) as t_operand
32 33 34 35 36 37 38 39 40
declare function asm_encode_register(register_name as string) as ubyte
declare function asm_decode_register(reg as ubyte) as string
declare function asm_encode_opcode(instruction as string) as ubyte
declare function asm_decode_opcode(opcode as ubyte) as string
declare function asm_operand_count(opcode as ubyte) as ubyte
declare sub asm_assemble(instruction as string)
declare function asm_disassemble(page as ushort, offset as ushort) as string
declare function asm_bytes_to_ushort(lsb as ubyte, msb as ubyte) as ushort
declare sub asm_assemble_interactive(origin_address as ushort)
41
declare sub asm_disassemble_range(page as ushort, start_offset as ushort, count as ushort)