FAQ
I tried some code but its not working :(

package main


func main(){
const VIDEORAM = 0X000A0000
var src *byte = *byte(VIDEORAM)
*src = 's'
*src = src + 2
*src = 'c'
*src = src + 2
*src = 'r'
*src = src + 2
*src = 'e'
*src = src + 2
*src = 'e'
*src = src + 2
*src = 'n'
}

--

Search Discussions

  • Minux at Dec 20, 2012 at 6:51 pm

    On Fri, Dec 21, 2012 at 12:48 AM, Kernel Srinivasan wrote:

    I tried some code but its not working :(
    Go doesn't have pointer arithmetics, and you will need to use
    unsafe.Pointer to covert
    an arbitrary number to a pointer.
    However, you can use slice to partially emulate simple pointer arithmetics.
    package main
    import "unsafe"

    func main(){
    const VIDEORAM = 0X000A0000
    const VIDEORAM uintptr = 0x000a0000
    srcArr := (*[1<<30]byte)(unsafe.Pointer(VIDEORAM))
    src := srcArr[:]
    var src *byte = *byte(VIDEORAM)
    *src = 's'
    src[0] = 's'
    *src = src + 2
    src = src[2:]
    *src = 'c'
    src[0] = 'c'
    // etc.
    *src = src + 2
    *src = 'r'
    *src = src + 2
    *src = 'e'
    *src = src + 2
    *src = 'e'
    *src = src + 2
    *src = 'n'
    }
    I doubt whether you can actually run this code, as you're directly
    accessing the video
    memory with its physical address, and normal Go implementation requires a
    virtual
    memory environment where accesses are made with virtual addresses.

    What do you really plan to do?

    --
  • Bryanturley at Dec 20, 2012 at 9:29 pm

    On Thursday, December 20, 2012 12:50:41 PM UTC-6, minux wrote:

    On Fri, Dec 21, 2012 at 12:48 AM, Kernel Srinivasan <kernel.s...@gmail.com<javascript:>
    wrote:
    I tried some code but its not working :(
    Go doesn't have pointer arithmetics, and you will need to use
    unsafe.Pointer to covert
    an arbitrary number to a pointer.
    However, you can use slice to partially emulate simple pointer arithmetics.
    package main
    import "unsafe"

    func main(){
    const VIDEORAM = 0X000A0000
    const VIDEORAM uintptr = 0x000a0000
    srcArr := (*[1<<30]byte)(unsafe.Pointer(VIDEORAM))
    src := srcArr[:]
    var src *byte = *byte(VIDEORAM)
    *src = 's'
    src[0] = 's'
    *src = src + 2
    src = src[2:]
    *src = 'c'
    src[0] = 'c'
    // etc.
    *src = src + 2
    *src = 'r'
    *src = src + 2
    *src = 'e'
    *src = src + 2
    *src = 'e'
    *src = src + 2
    *src = 'n'
    }
    I doubt whether you can actually run this code, as you're directly
    accessing the video
    memory with its physical address, and normal Go implementation requires a
    virtual
    memory environment where accesses are made with virtual addresses.

    What do you really plan to do?
    Not to mention that if you are in any OS + any GUI the memory at 0xA0000 is
    probably disabled or remapped/ignored in the video card for a real
    framebuffer at a different address.
    That memory location was for the video devices in old 8086 16bit + 4bit
    segment selector days, meaning the entire framebuffer/textbuffer was 64K
    wide without windowing tricks.

    Comically lspci -vvx tells me my video ram is currently located at
    0xA0000000. The bios and/or os/video driver decide where to place it
    during system boot.
    Note that is video ram not start of the frame buffer.

    It would be better to learn something like opengl or in your example's case
    ncurses.
    The days of simple standardized video devices are long gone <sniffle>.

    --
  • Johann Höchtl at Dec 20, 2012 at 11:03 pm
    And that was video mode ram. Text mode started at B800. Sniffle, sniffle

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 20, '12 at 6:39p
activeDec 20, '12 at 11:03p
posts4
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase