Results 1 to 6 of 6

Thread: easy newbie question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Posts
    299

    Unhappy easy newbie question

    I am using NASM linker to make executables, how do I declare variables for it? Please tell me for each data type, including strings and arrays.

  2. #2
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    declare a variable:

    Variable db 0x00 ; Declares a variable, 1 byte. Init to 0
    Variable dw 0x0000 ; Declares a word(2bytes - integer)
    Variable dd 0x00000000 ; Declares a double word(4bytes - long)

    It is possible to do this...
    Variable:
    dw 0
    dw 1 ; An array looking like {0,1}

    Variable db dup 20 ; I am sure that this creates a 20-byte array

    Variable db dup ? ; This should create a byte array of an unknown length
    Designer/Programmer of the Comtech Operating System(CTOS)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Posts
    299
    thank you. how would you go about filling the array or getting data from the array? ie. how would you convert the following C code?

    int nArray[3];
    int nBuffer;

    nArray[1]=100;
    nArray[2]=400;
    nArray[3]=125;
    nBuffer=nArray[1];

  4. #4
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    I'll use
    nArray[2]=400;
    ...as an example:

    nArray dw dup 3 ; I think this is correct

    mov [nArray + 2], 400 ; Put 400 into the address of nArray plus
    ; 2 because you want the second position. Simple, no?


    Try it out. I'm fairly sure this is the right way, but I'm only an intermediate assembler programmer
    Designer/Programmer of the Comtech Operating System(CTOS)

  5. #5
    Writing his own OS, but only intermediate

  6. #6
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    It's the C programming that I'm good at... Assembler will come in time.

    The OS loader works, so I'm happy for that. It will load a kernel.bin into the memory(point 0x1000) from the root directory, so long as the file fits below that 1MByte address line (The A20). The boot code supports FAT, but is too big to add the ~100bytes of code to open the A20 line for expanded memory. I shall change this.

    Intermediate, yes... but I have the logic flow and know-how thanks to C and C++...

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

    LOL, BTW: I somehow killed my entire windows directory on my 486 PC. When it died, I checked the disk and a 2.6GByte file was sitting on my poor, sad 1.28GByte drive. The file had some very wierd characters in the name field. How that happened I do not know... Maybe it misreported? Maybe windows? Anyways, both hard disks (Were bootable by changing wires) are non-bootable. I was trying to put together a compact windows, but stupid win95 said "The registry file is unavailable" and then it went. I need to get my 850MByte hard disk from my friend to fix this error...
    Designer/Programmer of the Comtech Operating System(CTOS)

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