Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 914763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:46:18+00:00 2026-05-15T17:46:18+00:00

I would like to have this x86 ASM code ported to C or C++,

  • 0

I would like to have this x86 ASM code ported to C or C++, as I don’t understand ASM =)

Searching Google it seams Relogix and IDA Pro can do it. But I don’t suppose they are cheap, given I only have this one source.

Understanding the math or the algorithm how it works would be just as good, as I am going to use OpenGL anyway.

Are there other methods?

;
;  a n d r o m e d a 
;                        
;  a 256b demo
;  by insomniac/neon
;
code    SEGMENT
    ASSUME  CS:code, DS:code
    p386
    LOCALS

ORG 100h

max =   4096
maxZ    =   5000

b   EQU byte ptr

Start:  lea di,vars
    mov ch,60
    rep stosw

    mov al,13h
    int 10h

p    al:    mov al,cl
    mov dx,3c8h
    out dx,al
    inc dx
    cmp al,64
    jb  b64_1
    mov al,63
b64_1:  out dx,al
    mov al,cl
    shr al,1
    out dx,al
    out dx,al
    loop    pal


.main:  push    8000h
    pop ES

    mov si,max

.loop:  mov ax,Z[si]
    cmp ax,maxZ-(maxZ/4)
    jg  NewStar
    cmp ax,2
    jg  Zok
NewStar:
    mov ax,bp
    mov X[si],ax

    imul    ax,8405h
    inc ax
    mov bp,ax

    shr ax,6
    sub ax,400
    mov Y[si],ax

    mov Z[si],maxZ-(maxZ/2)

Zok:    mov ax,X[si]
    movsx   dx,ah
    shl ax,8

    mov cx,Z[si]

    idiv    cx
    add ax,320/2
    cmp ax,320-1
    jge NewStar
    cmp ax,1
    jle NewStar

    mov di,ax

    mov ax,Y[si]
    movsx   dx,ah
    shl ax,8
    idiv    cx
    add ax,200/2

    imul    ax,320
    add di,ax

    mov al,127
    stosb

    mov ax,X[si]
    cmp ax,00
    jge .add
    neg ax
    shr ax,6
    add Y[si],ax
    jmp .notadd
.add:   shr ax,6
    sub Y[si],ax
.notadd:
    add Z[si],ax
    mov ax,Y[si]
    sar ax,3
    add X[si],ax

.NextStar:
    dec si
    dec si
    jnz .loop

    push    DS
    push    ES
    pop DS

    xor di,di
    xor cx,cx
.blur:  movzx   ax,DS:[di]
    movzx   dx,DS:[di+1]
    add ax,dx
    mov dl,DS:[di-320]
    add ax,dx
    mov dl,DS:[di+321]
    add ax,dx
    shr ax,2

    cmp al,0
    je  .skip
    dec ax

.skip:  stosb
    loop    .blur

    push    0a000h
    pop ES

    mov si,di
    mov ch,81h
    rep movsw

    pop DS

    mov dx,3dah
.vrt:   in  al,dx
    test    al,8
    jz  .vrt

    in  al,60h
    dec ax
    jnz .main

endprog:
    mov al,3
    int 10h

    ret

LABEL   vars
X   dw  max DUP (?)
Y   dw  max DUP (?)
Z   dw  max DUP (?)

code    ENDS
    END Start
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:46:19+00:00Added an answer on May 15, 2026 at 5:46 pm

    In general case, this cannot be done. In this particular case, this cannot be done because this assembly program interacts with PC BIOS directly, using int 10h to turn on 320×200 256 VGA mode, and it interacts with PC hardware directly, by writing to IO ports 0x3c8 and 0x3c9 (this sets the VGA palette) and by reading from 0x3da (VGA status register) and 0x60 (PC keyboard microcontroller). It also writes directly to VGA video memory.

    Under the conditions of executing on a PC-compatible computer with MS-DOS or similar OS (or, within a simulated environment such as dosbox), this can be done: you can either make each CPU register a C variable and each assembly mnemonic a C function that modifies those variables or writes at absolute memory addresses or IO ports (with outb() and inb()), or, and I think this would be a much more interesting task, understand the math this demo does, and implement that in a portable manner.

    Either way, I haven’t heard of tools that could do this automatically. Existing tools might handle simple logic, but understanding a demo is never an easy task! What automatic program can tell that

    imul    ax,8405h
    inc ax
    

    should be replaced with ax = rand();?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code, which works fine, but I would like to be able
Suppose I have this Windows wchar_t string: L\x4f60\x597d and L\x00e4\x00a0\x597d and would like to
I would like to have a nice template for doing this in development. How
I have seen this problem arise in many different circumstances and would like to
I would like to ask for a reccomended solution for this: We have a
hi i would like to create a custom calendar, this calendar will have custom
I have a layout similar to this: <div id=...><img src=...></div> and would like to
If I have a double (234.004223), etc., I would like to round this to
I have a problem that I would like have solved via a SQL query.
I would like to have a reference for the pros and cons of using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.