Re: Excercices

From: Annie (me_at_privacy.net)
Date: 11/01/04


Date: Mon, 1 Nov 2004 22:55:41 +0000 (UTC)


On 2004-11-01 klee@unibwm.de said:

> That is a typical answer of a politician, but that doesn't
> work with me. Let's repeat your original statement:
>
> AA> Don't give me too much grief, Herbie. My version was only
> AA> 85 bytes. Your version was -248- bytes. Hehe!
>
> You write: "My version WAS ..." and not "my now shorted version
> is". This definitely claims, that the version posted in
> <416641fe@post.newsfeeds.com> at Fri, 08 Oct 2004 14:03:59 +0200
> had 85 bytes. This is untrue. If you assemble the posted source
> with a86 you get a 175 byte com file.

You are correct, Herbie. As I mentioned in my previous message,
that version contained routines to check for 386 or higher, and
to check for VGA video.

You said they were not necessary, so I removed them.

> AA> Herbie's 'batch file encoded' executable, which he posted
> AA> here, decoded to 248 bytes.
>
> Yes, but you was aware, that this is not the code size
> of the heart program, but the sum of the size of the decoder
> routine and the ascii encoded program.

You are correct; I was aware of that.

> AA> I didn't assemble his actual source code, because it was
> AA> written in Herb-Asm...his own 68K-style assembly language.
>
> This wasn't necessary at all. In a wise foresight, I didn't
> post the source code but the listing of the program and this
> listing ends with:
>
> 0000014f: b8 0000 move.w #0,r0
> 00000152: cd 16 trap #$16
> 00000154: b8 0003 move.w #$0003,r0
> 00000157: cd 10 trap #$10
> 00000159: c3 rts.w
>
> So, without assembling you can see, that the last byte of the
> code is byte 0x59 (89) which gives a length of 90 bytes.

Yes; you are correct, Herb.

> AA> Herb -DID- correct a 'bug' that was introduced by my
>
> I did, but you still didn't.

You are correct.

> AA> porting of the code to 16-bit A86...which caused a
> AA> slight misalignment of the screen image.
>
> It doesn't "cause a slight misalignment of the screen image"

Actually, it does....a very slight 'tearing,' near the
bottom of the screen.

> but the program can complete fail dependent of the values in
> upper half of the 32 bit registers at program start.

You might be correct, but I did not experience that.

> AA> Hopes this clears things up. Hehe!
>
> Yes and it also clears why we need Bush for another
> 4 year to make the world more save.

Hehe! You are talking to the wrong person, Herb. I have said
many times that I am NOT a supporter of Bush. He is too liberal
for me.

In the American elections, I will vote for Michael Peroutka, of
the Constitution Party.

> AA> Here's the 'batch file' version that Herbert originally
> AA> posted:
>
> And where is the listing I originally posted? The information was
> there and not in the batch code.

You are correct.

> AA> And here's my 16-bit A86 ASM version:
>
> Still with all the bugs I already mentioned.

                                             _____
       Again, you are correct. ((( `\
                                            _ _`\ )
       But let's not fight, Herbie. (^ ) )
       Let's enjoy a nice meal of ~-( )
       bratwurst and sauerkraut! _'((,,,)))
                                          ,-' \_/ `\
       Here is some ASM code as a ( , |
       'peace offering.' `-.-'`-.-'/|_|
                                             \ / | |
                                              =()=: / ,' aa
;
; MEMVIEW.ASM
; Fast Full-Screen Raw Memory Viewer For DOS
; Freeware
;
; This code assembles, as-is, with the A86 assembler.
;
code segment ;start of code segment
        org 100h ;DOS .COM file
        jmp start ;go do it
;
vid_add dw 0B800h ;our video address storage
stor_2 dw 0 ;our memory location storage
;
start:
        call curs_off ;go turn off cursor
;
; Check for monochrome video. If found, store the appropriate address.
;
        int 11h ;call BIOS equipment check
        and ax,30h ;test the return in AX
        cmp ax,30h ;do we have monochrome video?
        jne zero ;no, so assume color
        mov vid_add,0B000h ;yes, so store monochrome video address
;
; Set up and store our memory addresses, clear the screen,
; display the program's status line to the screen, and
; show the first screenful of data.
;
zero:
        xor ax,ax ;set memory address 0000:0000
        mov stor_2,ax ;store it
        call clr_scrn ;go clear the screen
        call stat_line ;go display the status line
        jmp fill_scrn ;go display memory data
;
; Get a keypress from the user, and act accordingly.
; (We're checking scan codes here; not ASCII characters.)
;
get_key:
        mov ah,0 ;function 0 - wait for keypress
        int 16h ;call ROM BIOS keyboard services
        cmp ah,1 ;ESC key pressed?
        je exit ;yes, so go exit
        cmp ah,51h ;PG DN key pressed?
        je next_scrn ;yes, so go forward one screen
        cmp ah,49h ;PG UP key pressed?
        je prev_scrn ;yes, so go back one screen
        cmp ah,50h ;DOWN ARROW key pressed?
        je next_line ;yes, so go forward 1 line
        cmp ah,48h ;UP ARROW key pressed?
        je prev_line ;yes, so go back one line
        cmp ah,47h ;HOME key pressed?
        je home ;yes, so go to beginning of memory
        cmp ah,4Fh ;END key pressed?
        je end_mem ;yes, so go to end of memory
        jmp get_key ;go get another keypress
;
exit:
        call curs_on ;go turn cursor on
        call clr_scrn ;go clear the screen
        int 20h ;exit to DOS
;
next_scrn:
        mov ax,stor_2 ;retrieve memory pointer
        add ax,120 ;increment 24 lines
        mov stor_2,ax ;store it
        jmp fill_scrn ;go display memory data
;
prev_scrn:
        mov ax,stor_2 ;retrieve memory pointer
        sub ax,120 ;decrement 24 lines
        mov stor_2,ax ;store it
        jmp fill_scrn ;go display memory data
;
next_line:
        mov ax,stor_2 ;retrieve memory pointer
        add ax,5 ;increment by 80 bytes
        mov stor_2,ax ;store it
        jmp fill_scrn ;go display memory data
;
prev_line:
        mov ax,stor_2 ;retrieve memory pointer
        sub ax,5 ;decrement by 80 bytes
        mov stor_2,ax ;store it
        jmp fill_scrn ;go display memory data
;
home:
        mov stor_2,0 ;set memory pointer to 0000:0000
        jmp fill_scrn ;go display memory data
end_mem:
        mov stor_2,65416 ;set pointer to show last screen of memory
;
; Fill the screen with memory contents.
;
fill_scrn:
        mov cx,1920 ;set counter CX to 1920
        xor si,si ;zero out SI
        xor di,di ;zero out DI
do_more:
        mov ax,stor_2 ;retrieve memory pointer
        mov es,ax ;point our Extra Segment to that location
        mov es: dl,[si] ;
        mov ax,vid_add ;video address in AX
        mov es,ax ;point our Extra Segment to video address
        mov es: [di],dl ;
        inc si ;
        inc di ;next text cell
        inc di ;skip attribute cell
        dec cx ;decrement counter
        jnz do_more ;go again while CX > 0
        jmp get_key ;go get a keypress from user
;
;****************************************
; Sub-routines.
;****************************************
;
; Turn off cursor.
;
curs_off:
        mov ch,10h ;set bits to turn cursor off
        mov ah,1 ;function 1 - cursor control
        int 10h ;call ROM BIOS video services
        ret ;return to caller
;
; Turn cursor on.
;
curs_on:
        mov cx,0506h ;set bits to turn cursor on
        mov ah,1 ;function 1 - cursor control
        int 10h ;call ROM BIOS video services
        ret ;return to caller
;
; Clear the text-mode screen by over-writing video memory,
; and home the cursor.
;
clr_scrn:
        mov ax,vid_add ;start of screen RAM in AX
        mov es,ax ;set Extra Segment to video address
        mov di,0 ;displacement on screen (0,0) in DI
        mov cx,4000 ;number of WORDS
        mov ax,0700h ;color attribute (7=white)
        cld ;clear direction flag
clearloop:
        stosw ;mov [es:di],ax | inc di | inc di
        loop clearloop ;dec cx | cmp cx,0 | jnz clearloop
;
        mov ah,2 ;function 2 - set cursor position
        mov bh,0 ;set page
        xor dx,dx ;row 0, column 0
        int 10h ;call ROM BIOS video services
        ret ;return to caller
;
; Move the status line directly to video memory.
;
stat_line:
        mov cx,80 ;read 80 words
        xor dx,dx ;zero out register DX
        mov ax,vid_add ;video address into AX
        mov es,ax ;move it into ES
        mov di,80*48 ;location 24,0
        mov si,offset ldat ;point SI to the status line data
        rep movsw ;move the entire string at once
        ret ;return to caller
;
ldat db ' 0 0M0E0M0V0I0E0W0 0v0.0 000.000 0 0',221,'0 0'
        db ' 0P0g0D0n0 0 0P0g0U0p0 0 0',25,'0 0 0',24,'0 0 0H0'
        db 'o0m0e0 0 0E0n0d0 0 0E0S0C0=0Q0u0i0t0 0 0'
        db 222,'0 0 0 0 0 0F0r0e0e0w0a0r0e0 0 0 0 0 0 0'
;
end



Relevant Pages

  • Re: Excercices
    ... for graphics/sprites to steal from other programs (I'm not ... load the program into the screen memory map. ... show the first screenful of data. ... >; Turn off cursor. ...
    (alt.lang.asm)
  • Re: segmentation fault sometimes
    ... These values are fixed to a specific video card. ... I still don't figure out the root cause till now why it access memory ... It looks like the yoffset is causing your trouble. ... You've got a lot more video RAM than you'd need to store a screenful of ...
    (comp.lang.c)
  • Re: Advice on Logic Analyzer
    ... If it where my money I would get the ... janatekbecause it has 1mbit/channel memory. ... as evidenced by the "entire screenful" ...
    (sci.electronics.design)
  • Re: Memory usage
    ... > Use a tool to watch free memory as your system runs. ... try lookingoon the Hobbes download site. ... Also monitor CPU usage to ... >>opening screen it prints a screenful of greek carachters where I would ...
    (comp.os.os2.misc)