Thread: Visual Basic vs C++

  1. #61
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Actually all languages except maybe scripting languages will allow you to directly access memory. And while BASIC does not have pointers per se....actually it does have pseudo pointers.

    BASIC code to demo direct memory access
    Code:
    Screen 13
    DEF SEG=&HA000
     
    poke 32000,15
     
    DEF SEG
     
    dim MyArray(0 to 20) as integer
     
    offsetMyArray%=VARPTR(MyArray)
    segmentMyArray%=VARSEG(MyArray)
    print"MyArray address: ";segmentMyArray%;":";offsetMyArray%
     
    DEF SEG=segmentMyArray%
     
    for i%=0 to 20
    poke offsetMyArray%+i%,int(rnd(1)*255)+1
    next
     
    DEF SEG

    DEF SEG is where poke will place a byte into memory and where peek will read a byte from. So in a sense this is a pointer. You can also call functions via pointers using VARSEG and VARPTR but QB 7.1 also allows you to simply call assembly language subroutines. Of course the assembly must use the small memory model and cannot have stack or data that exceed 64KB, but it is possible to combine assembly and QB.

    It should be noted to that it is possible to program the DMA controller, floppy drive controller, etc. in QB as well. You can also use interrupts via CALL INTERRUPT and CALL INTERRUPTX or in old QB 45 you could embed assembly opcodes into your code, create a subroutine out of it by creating a pointer to the asm opcode string (using VARPTR) and simply call it with CALL ABSOLUTE.

    You can also read memory with QB. This program will print out all the addresses that are in the IVT or interrupt vector table. You could even write code that would display the actual asm code for the handler at the address. You could then write code in QB as well to decode the opcodes into actual assembly instructions. Thus you could write a disassembler in pure QuickBasic code.

    Code:
    DEF SEG=0
     
    moffset%=0
    do
    print"0000:";
    ofst$=str$(moffset%);
    length=len(ofst$)
    ofst$=string$(4-length,"0")+ofst$
    print ofst$;" ";
    for i%=0 to 31
    byte%=asc(peek(i%+moffset%))
    asciichar$=chr$(byte%)
    text$=hex$(byte%)
    if len(text$)<2 then text$="0"+ text$
    print text$;" ";
    if byte%<>7 and byte%<>13 and byte%<>32 and byte%<>8 then asciichar$="."
    locate ,80-i:print asciichar$
    next
    moffset%=moffset%+32;
    loop until moffset%>=1020

    The only language that probably cannot directly manipulate/read memory like this would probably be FORTRAN or COBOL since there application/usage is much different than C/C++, Pascal, QuickBasic, etc.


    Sorry for all the BASIC code but I was proving a point.
    I won't even go into the asm code for that.



    Incidentally you can do much of this in VB as well and there are 'pointers' in VB, but they are ugly to say the least.
    Last edited by VirtualAce; 07-23-2004 at 06:11 PM.

  2. #62
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    >No, and I was here first
    Not if we judge by my original join date and yours.

  3. #63
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    603
    Uh??
    Visit entropysink.com - It's what your PC is made for!

  4. #64
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Robc - if you're aware that your link points to Prelude's profile, do you mean to tell me that it was YOU who gave Thantos a lap dance? http://cboard.cprogramming.com/showthread.php?t=55089

  5. #65
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    >do you mean to tell me that it was YOU who gave Thantos a lap dance?
    Don't tell me you actually believed that.

  6. #66
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    >i got it you are the the clone of Prelude
    My user settings seemed to be crippled for the Prelude account, so I made a new one.

  7. #67

  8. #68
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    >and how is that possible
    How is what possible? For my account to break or for me to create a new one? The former I have no clue, the latter I just log out and click the register link.

  9. #69
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    well IIRC she couldn't change the avatar

    But why the change in birthdays? Now thats the main question

  10. #70
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    >But why the change in birthdays? Now thats the main question
    I don't suppose you would accept me saying that it's a long story and you don't want to be bored by it?

  11. #71
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    You should know us better then that. We love long stories

  12. #72
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    603
    ..... and why Robc? Why not your real name or something?
    Visit entropysink.com - It's what your PC is made for!

  13. #73
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Robc's full legal name is, "SilverCord Prelude Robc"

  14. #74
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    I'd really rather not go into it if it's all the same to you guys.

  15. #75
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    please do.

    Storytime!

    *puts popcorn in the microwave*
    My Website

    "Circular logic is good because it is."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 11-23-2007, 12:13 AM
  2. Run Visual Basic code inside C++?
    By torbjoen in forum Windows Programming
    Replies: 8
    Last Post: 07-31-2002, 11:41 PM
  3. <list>
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 02-24-2002, 04:07 PM
  4. Visual Basic C++
    By gussguss in forum C++ Programming
    Replies: 8
    Last Post: 11-20-2001, 10:58 AM