Menu

struc

2012-03-23
2013-04-20
  • Hjort Nidudsson

    Hjort Nidudsson - 2012-03-23

    Using struct member as argument to invoke (16bit) seems to fail, like:

        invoke strcpy, addr config.cf_path, string
    

    Test code: (struc.asm):

    The segment part of the argument is (in some cases) adding offset.
    .model small
    .stack 128
    .data
    foo struc
    c_b1    db ?
    c_b2    db ?
    foo ends
    bar foo <?>
    .code
    start:  mov ax,seg bar.c_b2
        sub ax,seg _DATA
        mov ah,4Ch
        int 21h
    end start
    

    This works: (return 0)

    jwasm -mz struc.asm
    

    This fails: (return 1)

    jwasm struc.asm
    wlink F struc.obj SYS DOS
    
     
  • Steve A

    Steve A - 2012-04-05

    Untested on 16bit, but, this seems to work on 32bit:

    foo struct
    c_b1 db    20 dup(0)  ; or whatever string length
    c_b2 db    20 dup(0)
    foo ends
    bar foo <?>

      assume edi:PTR foo         ; point edi to struct
      mov edi, offset bar        ; load struct address
      invoke strcpy, addr .c_b1, addr string

      ; blah blah blah
      ; do stuff

      assume edi:nothing

     
  • japheth

    japheth - 2012-06-25

    I confirm the second error (struct member as operand for SEG operator)

    will be fixed in v2.07.

     
  • japheth

    japheth - 2012-06-26

    > Using struct member as argument to invoke (16bit) seems to fail, like:
    > invoke strcpy, addr config.cf_path, string

    You'll have to provide a full test case. I extended the code and I'm unable to see a problem:

    .model small
    .stack 128
    foo struc
    c_w1 dw ?
    c_s2 db 12 dup (?)
    foo ends
    strcpy proto c :ptr byte, :ptr byte
    .data
    bar foo <?>
    string dw szX
    szX db "abc",0
    .code
    main proc
    local x:foo
        invoke strcpy, addr bar.c_s2, string
        invoke strcpy, addr x.c_s2, string
        ret
    main endp
    start:
        mov ah,4Ch
        int 21h
    end start
    
     
  • Hjort Nidudsson

    Hjort Nidudsson - 2012-07-05

    As I remember (don’t find the old source) the strcpy code generated an exception, and I notice from the output that the segment was increased. I don’t remember the actual argument (.something), but I wrote the test from this assumption.

     

Log in to post a comment.