CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2009
    Posts
    1

    Need help with Printing Screen

    I am able to put values into AL and print using 'CALL PrintCharacter'

    but I couldnt print 'msg' with 'Call PrintString'

    am I missing anything here? please help


    ----------------------

    cpu 686

    use16

    segment .text
    %define TC_BIOS_KEY_ENTER 1ch

    GLOBAL Logger
    GLOBAL g_uLoggerCodeSize
    GLOBAL g_uCallAskPasswordDeltaOffset

    push ax
    push es

    push ds
    pop es ; put ds into es

    MOV ESI, msg
    Call PrintString

    .keypress:
    ;wait for keypress
    mov ah,0
    int 16h
    pop es
    pop ax
    .exit:
    pop bp
    ret ; cdecl

    ;----------- Procedures --------------

    PrintCharacter: ;Procedure to print character on screen
    ;Assume that ASCII value is in register AL

    PUSHA
    MOV AH, 0x0E ;Tell BIOS that we need to print one charater on screen.
    MOV BH, 0x00 ;Page no.
    MOV BL, 0x07 ;Text attribute 0x07 is lightgrey font on black background
    INT 0x10 ;Call video interrupt
    POPA
    RET ;Return to calling procedure


    ; ---- Dont work ----
    PrintString: ;Procedure to print string on screen
    ;Assume that string starting pointer is in register SI

    PUSHA
    next_character: ;Lable to fetch next character from string
    MOV AL, 88 ; X
    CALL PrintCharacter

    MOV AX, [ESI] ;Get a byte from string and store in AL register
    INC ESI ;Increment SI pointer
    OR AX, AX ;Check if value in AL is zero (end of string)
    JZ exit_function ;If end then return
    CALL PrintCharacter ;Else print the character which is in AL register
    JMP next_character ;Fetch next character from string

    exit_function: ;End label
    MOV AL, 87 ; W
    CALL PrintCharacter

    POPA
    RET ;Return from procedure

    msg dw 'Hello, world!',0xa ;our dear string

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: Need help with Printing Screen

    Code:
    OR AX, AX	 ;Check if value in AL is zero (end of string)
    JZ exit_function ;If end then return
    ...
    msg	dw	'Hello, world!',0xa	;our dear string
    I see a line feed character (0x0A) at the end of your string, but I don't see a null (binary zero) character. It's different from the C language where a null character is automatically appended to an array of characters.
    But I don't know if this is the cause of your problem.
    Try to see what happens with only the first character, when you remove JMP next_character.

    And please, use PHPBB tags, i.e. write [code] before, and [/code] after your lines of codes when you post them here.
    Last edited by olivthill2; November 2nd, 2009 at 08:06 AM.

  3. #3
    Join Date
    Dec 2009
    Posts
    1

    Re: Need help with Printing Screen

    Apparently what we're "missing" is that this is supposed to be a module
    linked with gcc(!). Yeah, I know it's 16-bit code. There are some kernel
    services that will put us in vm86 mode - dosemu apparently does it that
    way. I'm waiting for further details on what's in the "other module"
    that this is linked against. See c.l.a.x.

    ...

    >> msg dw 'Hello, world!',0xa ;our dear string

    The "dear string" comment ought to have been a tipoff. I first saw this
    comment in an example in the assembly "howto" by Konstantin Boldyshev.
    I've copied it around a bit - I suppose other people have, too, but
    that's where it "comes from", AFAIK.

    > First I have no idea why you precede all characters with an "X"
    > and end with "W", if the code is 16 bit, then you better use:

    Just a "debugging test", I think. Apparently it works(?). There's a
    "Linux Real Mode Interface" library available at SourceForge - this
    *may* be what Zhane's using.

    > MOV SI,msg ;why ESI ?

    Apparently si gets a complaint from ld. I suspect he may want si, but
    may need to "do something different" to let gcc/ld know it's "okay".
    Perhaps a 16-bit section ("use16" in the section declaration, rather
    than "freestanding")... Or ????



    http://www.techstore.ie/Design-Print

  4. #4
    Join Date
    Dec 2009
    Posts
    1

    Re: Need help with Printing Screen

    The screen consists of three negatives, one in cyan, one in magenta and the other in yellow. There is one unmasked colour print and one masked print. The image printed is a photograph of a number of objects on a table top, including a green handbag, a travel clock, a pair of white gloves and two silver sailing ship ornaments.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured