Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

FreeBSD assembler question

dantechrist666dantechrist666 Member Posts: 23
The flags specified are formed by or'ing the following values

O_RDONLY open for reading only
O_WRONLY open for writing only
O_RDWR open for reading and writing
O_NONBLOCK do not block on open
O_APPEND append on each write
O_CREAT create file if it does not exist
O_TRUNC truncate size to 0
O_EXCL error if create and file exists
O_SHLOCK atomically obtain a shared lock
O_EXLOCK atomically obtain an exclusive lock

(copied directly from man 2 open)
What does or'ing do? How does one or?
Thanks!

Comments

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    mov ax, O_RDONLY or O_EXLOCK or O_XXX_ANYTHING_ELSE


  • dantechrist666dantechrist666 Member Posts: 23
    : mov ax, O_RDONLY or O_EXLOCK or O_XXX_ANYTHING_ELSE
    :
    :
    Thanks, are you sure? The man page says that argument is int, however I'll try it anyway.
    (I know those are just strings of ints, but I don't think that's what it means...)
    Thanks.

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    If we talking about x86 Assembler (what is FreeBSD anyway?) then
    this is how we combine masks in a register. The best way to be sure is to write a small ASM program and step inside with the debugger...

    MASK1 equ 0004h
    MASK2 equ 0040h
    MASK3 equ 0400h
    MASK4 equ 4000h

    ...
    mov ax, MASK1 or MASK2 or MASK3 or MASK4
    ; --- if result in AX will be 4444h, then it works!


  • dantechrist666dantechrist666 Member Posts: 23
    : If we talking about x86 Assembler (what is FreeBSD anyway?) then
    : this is how we combine masks in a register. The best way to be sure is to write a small ASM program and step inside with the debugger...
    :
    : MASK1 equ 0004h
    : MASK2 equ 0040h
    : MASK3 equ 0400h
    : MASK4 equ 4000h
    :
    : ...
    : mov ax, MASK1 or MASK2 or MASK3 or MASK4
    : ; --- if result in AX will be 4444h, then it works!
    :
    :
    FreeBSD is a unix variant running on just about any processor above a 286. My question was referring specifically to the example I gave. I thought that or'ing was (like that) dealing more with numbers, not the strings (the only thing it gives).

  • dantechrist666dantechrist666 Member Posts: 23
    I just found the numbers, forgot it gave a c include file if I wanted to program this in c. Thanks for all the help!!!

Sign In or Register to comment.