I am trying to print a string that contains the ascii letters signatures of the master boot record

89 Views Asked by At

But it just prints an empty string, unless I set the address to something like 0x00 or 0x20, then it prints some ascii characters . Also I am new to assembly and x86 segmentation so I barely know if I am doing things right .

INT 10H 1300H: Display String

 Expects: AX    1300H
          BH    video page
          BL    video attribute
          CX    length of string
          DH,DL row,column to start writing
          ES:BP address of start of text to write
          ──────────────────────────────────────────────────────────────────
 Returns: (none)

So far my code is:

            // Stack Segment

            new MovInstruction_Register16Bit_Immediate16Bit(Register8086.AL, offset),
            new MovInstruction_Segment16Bit_RegisterImmediate16Bit(Register8086.DL, Register8086.AL),
            new MovInstruction_Register16Bit_Immediate16Bit(Register8086.AH, 0x00),
            new MovInstruction_Register16Bit_Immediate16Bit(Register8086.CH, size),

            // Extra Segment

            new MovInstruction_Register16Bit_Immediate16Bit(Register8086.BL, offset),
            new MovInstruction_Segment16Bit_RegisterImmediate16Bit(Register8086.AL, Register8086.BL),
            new MovInstruction_Register16Bit_Immediate16Bit(Register8086.BH, 0x00),

            // Main

            new MovInstruction_Register16Bit_Immediate16Bit(Register8086.AL, 0x1300),
            new MovInstruction_Register8Bit_Immediate8Bit(Register8086.BH, videoPage),
            new MovInstruction_Register8Bit_Immediate8Bit(Register8086.BL, videoAttribute),
            new MovInstruction_Register16Bit_Immediate16Bit(Register8086.CL, lengthOfString),
            new MovInstruction_Register8Bit_Immediate8Bit(Register8086.DH, row),
            new MovInstruction_Register8Bit_Immediate8Bit(Register8086.DL, column),
            //new MovInstruction_Register16Bit_Immediate16Bit(Register8086.CH, size),
            //new MovInstruction_Register16Bit_Immediate16Bit(Register8086.AH, offset),
            //new MovInstruction_Segment16Bit_RegisterImmediate16Bit(Register8086.AL, Register8086.AH),

And my disassembly is:

// Stack Segment

0x0000000000000000:  B8 00 7C    mov ax, 0x7c00
0x0000000000000003:  8E D0       mov ss, ax
0x0000000000000005:  BC 00 00    mov sp, 0
0x0000000000000008:  BD 01 00    mov bp, 1

// Extra Segment

0x000000000000000b:  BB 00 7C    mov bx, 0x7c00
0x000000000000000e:  8E C3       mov es, bx
0x0000000000000010:  BF 00 00    mov di, 0

// Main

0x0000000000000013:  B8 00 13    mov ax, 0x1300
0x0000000000000016:  B7 00       mov bh, 0
0x0000000000000018:  B3 4D       mov bl, 0x4d
0x000000000000001a:  B9 00 02    mov cx, 0x200
0x000000000000001d:  B6 00       mov dh, 0
0x000000000000001f:  B2 00       mov dl, 0
//0x0000000000000021:  BD 01 00    mov bp, 1
//0x0000000000000024:  BC 00 7C    mov sp, 0x7c00
//0x0000000000000027:  8E C4       mov es, sp
0x0000000000000029:  CD 10       int 0x10
1

There are 1 best solutions below

5
Todor Yanev On
    WriteString ws = new WriteString(
            videoPage: 0x00,
            videoAttribute: 0x4D,
            lengthOfString: 512,
            row: 0,
            column: 0,
            offset: 0x7C0, <------ This works !
            size: 0x0
            );

    AssemblyEditor assemblyEditor;

    assemblyEditor = new MicroLinker(
        new SaveDriveNumber(0x7C00),
        ws
        );

And this does not

        WriteString ws = new WriteString(
                videoPage: 0x00,
                videoAttribute: 0x4D,
                lengthOfString: 512,
                row: 0,
                column: 0,
                offset: 0x7C00,
                size: 0x0
                );

        AssemblyEditor assemblyEditor;

        assemblyEditor = new MicroLinker(
            new SaveDriveNumber(0x7C00),
            ws
            );