flat assembler
Message board for the users of flat assembler.

Index > Windows > 17 byte demo! in WinXP

Author
Thread Post new topic Reply to topic
arcangel



Joined: 19 Aug 2009
Posts: 39
arcangel
I found this little demo

http://board.flatassembler.net/topic.php?t=9147

Code:
use16  
org 0x100  
mov ax,0x13  
int 0x10  
push word 0xA000  
pop es  
paint:  
adc ax, cx  
stosb  
loop paint  
inc ax  
jmp paint
    


Now I want to run in a window of Windows-XP

Code:
include 'win32ax.inc' ; you can simply switch between win32ax, win32wx, win64ax and win64wx here
org 0x100
mov ax,0x13  
int 0x10  
push word 0xA000  
pop es  
paint:  
adc ax, cx  
stosb  
loop paint  
inc ax  
jmp paint 
    


But it doesn't work in windows-XP ¿Why?

Thanks [/code]
Post 03 May 2014, 19:41
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
this demo writes directly to video memory at address 0xa000:xxxx which is for real mode. it's not valid for 32-bit windows running in protected mode
Post 03 May 2014, 19:46
View user's profile Send private message Reply with quote
arcangel



Joined: 19 Aug 2009
Posts: 39
arcangel
zhak wrote:
this demo writes directly to video memory at address 0xa000:xxxx which is for real mode. it's not valid for 32-bit windows running in protected mode


Will could somehow simulate?

Thank you very much for your help Smile
Post 03 May 2014, 20:08
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17346
Location: In your JS exploiting you and your system
revolution
It is a DOS program that is run under NTVDM in 32-bit Windows. So actually it is run in a VM. You won't be able to simply change it to a 32-bit program by changing the header. You also need substantial changes in the program to use the GDI and work with the OS windowing system.
Post 03 May 2014, 23:30
View user's profile Send private message Visit poster's website Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
This program can be easily ported to windows using JavaScript.

This will run in every modern browser with HTML5 Canvas support.
http://jsfiddle.net/q9y78/

demo.html
Code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript">

/* vga default 256 color palette [r1, g1, b1, ... r256, g256, b256] */
var VGA256 = [0,0,0,0,0,170,0,170,0,0,170,170,170,0,0,170,0,170,170,85,0,170,170,170,85,85,85,85,85,255,85,255,85,85,255,255,255,85,85,255,85,255,255,255,85,255,255,255,0,0,0,16,16,16,32,32,32,53,53,53,69,69,69,85,85,85,101,101,101,117,117,117,138,138,138,154,154,154,170,170,170,186,186,186,202,202,202,223,223,223,239,239,239,255,255,255,0,0,255,65,0,255,130,0,255,190,0,255,255,0,255,255,0,190,255,0,130,255,0,65,255,0,0,255,65,0,255,130,0,255,190,0,255,255,0,190,255,0,130,255,0,65,255,0,0,255,0,0,255,65,0,255,130,0,255,190,0,255,255,0,190,255,0,130,255,0,65,255,130,130,255,158,130,255,190,130,255,223,130,255,255,130,255,255,130,223,255,130,190,255,130,158,255,130,130,255,158,130,255,190,130,255,223,130,255,255,130,223,255,130,190,255,130,158,255,130,130,255,130,130,255,158,130,255,190,130,255,223,130,255,255,130,223,255,130,190,255,130,158,255,186,186,255,202,186,255,223,186,255,239,186,255,255,186,255,255,186,239,255,186,223,255,186,202,255,186,186,255,202,186,255,223,186,255,239,186,255,255,186,239,255,186,223,255,186,202,255,186,186,255,186,186,255,202,186,255,223,186,255,239,186,255,255,186,239,255,186,223,255,186,202,255,0,0,113,28,0,113,57,0,113,85,0,113,113,0,113,113,0,85,113,0,57,113,0,28,113,0,0,113,28,0,113,57,0,113,85,0,113,113,0,85,113,0,57,113,0,28,113,0,0,113,0,0,113,28,0,113,57,0,113,85,0,113,113,0,85,113,0,57,113,0,28,113,57,57,113,69,57,113,85,57,113,97,57,113,113,57,113,113,57,97,113,57,85,113,57,69,113,57,57,113,69,57,113,85,57,113,97,57,113,113,57,97,113,57,85,113,57,69,113,57,57,113,57,57,113,69,57,113,85,57,113,97,57,113,113,57,97,113,57,85,113,57,69,113,81,81,113,89,81,113,97,81,113,105,81,113,113,81,113,113,81,105,113,81,97,113,81,89,113,81,81,113,89,81,113,97,81,113,105,81,113,113,81,105,113,81,97,113,81,89,113,81,81,113,81,81,113,89,81,113,97,81,113,105,81,113,113,81,105,113,81,97,113,81,89,113,0,0,65,16,0,65,32,0,65,49,0,65,65,0,65,65,0,49,65,0,32,65,0,16,65,0,0,65,16,0,65,32,0,65,49,0,65,65,0,49,65,0,32,65,0,16,65,0,0,65,0,0,65,16,0,65,32,0,65,49,0,65,65,0,49,65,0,32,65,0,16,65,32,32,65,40,32,65,49,32,65,57,32,65,65,32,65,65,32,57,65,32,49,65,32,40,65,32,32,65,40,32,65,49,32,65,57,32,65,65,32,57,65,32,49,65,32,40,65,32,32,65,32,32,65,40,32,65,49,32,65,57,32,65,65,32,57,65,32,49,65,32,40,65,45,45,65,49,45,65,53,45,65,61,45,65,65,45,65,65,45,61,65,45,53,65,45,49,65,45,45,65,49,45,65,53,45,65,61,45,65,65,45,61,65,45,53,65,45,49,65,45,45,65,45,45,65,49,45,65,53,45,65,61,45,65,65,45,61,65,45,53,65,45,49,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];

var AX = 0;
var CX = 0;
var ES = 0;
var DI = 0;
var CF = 0;
/*
USE16   
ORG 0x100   
MOV AX,0x13   
INT 0x10   
*/
var canvas = document.createElement("canvas");
canvas.style.cssText="position:absolute;top:0;bottom:0;left:0;right:0;width:100%;height:100%;";
canvas.width = 320;
canvas.height = 200;
document.body.appendChild(canvas);
var ctx = canvas.getContext("2d");
/*
AL = ??? mode flag ???
*/
AX = 0x30;
/*
PUSH WORD 0xA000   
POP ES  
*/
ES = ctx.getImageData(0, 0, 320, 200);
/*
LABEL PAINT:
*/
var paint = function paint() {
    do {
        /* ADC AX, CX */
        AX += CX + CF;
        CF = (AX & 0x10000) > 0 ? 1 : 0;
        AX = AX & 0xFFFF;
        /* byte to rgb color */
        var colorIndex = AX & 0xFF,
                r = VGA256[colorIndex * 3],
                g = VGA256[colorIndex * 3 + 1],
                b = VGA256[colorIndex * 3 + 2];
        /* STOSB */
        ES.data[DI * 4] = r;
        ES.data[DI * 4 + 1] = g;
        ES.data[DI * 4 + 2] = b;
        ES.data[DI * 4 + 3] = 255;
        DI = (DI + 1) & 0xFFFF;
        /* LOOP PAINT */
        CX = (CX - 1) & 0xFFFF;
    } while(CX !== 0);
    /* image to screen */
    ctx.putImageData(ES, 0, 0);
    /* INC AX */
    AX = (AX + 1) & 0xFFFF;
    /* LOOP PAINT (delayed) */
    CX = (CX - 1) & 0xFFFF;
    if(CX !== 0) { window.setTimeout(paint, 0); return; }
};
paint();

</script>
</body>
</html>
    


The only value I fudged was the value of AX after the INT 10h.

*EDIT* http://jsfiddle.net/q9y78/1/ uses the "JMP paint" instead of a second "LOOP paint". Removing the poetic license changes the demo from scrolling to pulsating.
Post 05 May 2014, 16:26
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
> found this little demo http://board.flatassembler.net/topic.php?t=9147

Bad idea. Should be http://board.flatassembler.net/topic.php?t=9174

> But it doesn't work in windows-XP ¿Why?

Because the 17-Byte version is DOS code, and doesn't run natively in XP (or even 95).

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 22 May 2014, 09:24
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.