flat assembler
Message board for the users of flat assembler.

Index > DOS > DOS seeks (was '' ???????? ?????? ??????? ?? ???????? ?? '')


FASM challenge: Find out what this code is supposed to do - I'll post the solution later - Hint: it IS useful and works for me ;-)
This is great, I have the solution, see post
28%
 28%  [ 2 ]
This is CRAP, I refuse to participate !!!
28%
 28%  [ 2 ]
COOL ... but I have no idea :-|
42%
 42%  [ 3 ]
Total Votes : 7

Author
Thread Post new topic Reply to topic
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 29 Jul 2008, 06:45
.
.
Late EDIT : this one exposes the "64-bit-64-KiB-BUG" (fixed in Jan-2009 release ?) and slash-BUG (still present in Jan-2009 release) of EDR-DOS
.
.

Code:
; FASM (R) code | 486 Bytes
; Tests bugged handling of INT $21 / AX = $7142 and the "slash-BUG"
; in EDR-DOS and FreeDOS
; (CL) 2009-01-20 | Abuse at your own risk !!!
; Originally released 2008-Aug as "??????????????????????????"

define pope pop

format binary as "COM"
use16
org $0100

jmp near a99

a00: dw a01,a02,a03,a04,a05,a06,a07,a08,a09,a10,a11,a12

a01: db "C:\BLAH.XXX",0
a02: db "C:/BLAH.XXX",0
a03: db "C:\\BLAH.XXX",0
a04: db "C://BLAH.XXX",0
a05: db "C:\\\BLAH.XXX",0
a06: db "C:///BLAH.XXX",0
a07: db "C:\SUB\BLAH.YYY",0
a08: db "C:/SUB/BLAH.YYY",0
a09: db "C:\\SUB\\BLAH.YYY",0
a10: db "C://SUB//BLAH.YYY",0
a11: db "C:\\\SUB\\\BLAH.YYY",0
a12: db "C:///SUB///BLAH.YYY",0

a99:    call  seol
        mov   bx,a00
qq1:    mov   si,[bx]
        cmp   bx,a01
        je    short qq2 ; EOL
        add   bx,2
        push  bx        ; Counter
        push  si        ; Addr
        call  sprint
        call  sspc
        pope  dx        ; Addr
        mov   ax,$3D00  ; Open
        xor   cx,cx     ; MOVNTQ CX,0
        xor   di,di     ; MOVNTQ DI,0
        int   $21       ; Open
        adc   di,0      ; Very Happy
        push  ax        ; Hen / Err
        call  ssmil
        call  sspc
        mov   dl,62     ; ">"
        call  schar
        pope  ax        ; Hen / Err
        push  ax
        mov   cx,ax
qq7:    test  cx,cx
        jz    qq8
        dec   cx
        mov   dl,42     ; "*"
        call  schar
        jmp   short qq7
        ;--------------
qq8:    pope  bx        ; Hen / Err
        test  di,di     ; Was flag(C)
        jnz   qq3       ; F**K
        pope  ax        ; Counter
        push  ax
        cmp   ax,(a00+2)
        je    qq6       ; Leave opened
        mov   ah,$3E
        int   $21       ; Clo
        call  sspc
        mov   dl,67     ; "C"
        call  schar
        jmp   short qq3
        ;--------------
qq6:    mov   bp,bx     ; Save hen
qq3:    call  seol
        pope  bx
        jmp   short qq1
        ;--------------

qq2:     call  seol
         mov   di, $0100      ; Here "$" should be > $0210 ...
         mov   al, 1
         stosb
         stosb
         stosb
         mov   cx, di         ; $0103
         dec   al
         rep   stosb          ; BOOM Very Happy
         mov   bx, bp
         mov   ah, $3F        ; Read
         mov   dx, $110
         mov   si, dx
         mov   cx, 10
         int   $21
         call  sprint

        call  seol
        mov   dl,83     ; "S"
        call  schar
        call  sspc
        mov   ax,$7142
        mov   bx,bp
        mov   cl,1
        mov   dx,$100
        xor   di,di     ; MOVNTQ DI,0
        int   $21       ; Set
        adc   di,0      ; Very Happy
        mov   dx,di
        add   dl,48
        call  schar
        call  sspc
        mov   al, [$0100]
        add   al, [$0101]
        add   al, [$0102]
        cmp   al,3
        jne   @f        ; Did work
        mov   di,1
@@:     call  ssmil
        call  seol
        mov   bx,bp
        mov   ah,$3F    ; Read
        mov   dx,$120
        mov   si,dx
        mov   cx,10
        int   $21
        call  sprint
        jmp   short seol
        ;---------------

sspc:    mov  dl, 32
         ; pass

schar:   mov  ah, 2
         int  $21
         ; pass

qq0:     ret
         ;----

sprint:  lodsb
         cmp   al, 0
         je    short qq0
         cmp   al, 126
         ja    short qq9      ; Barring out garbage
         cmp   al, 31
         ja    short @f
qq9:     mov   al, 46         ; "." dot
@@:      mov   dl, al
         call  schar
         jmp   short sprint
         ;-----------------

seol:    mov   dl, 13
         call  schar
         mov   dl, 10
         jmp   short schar
         ;----------------

ssmil:   mov   dx, 41         ; 41 good | 40 bad
         sub   dx, di         ; 0 good  | 1 bad
         push  dx             ; Bra
         mov   dl, 58         ; ":"
         call  schar
         mov   dl, 45         ; "-"
         call  schar
         pope  dx             ; Bra
         jmp   short schar
         ;----------------

; END.
    


Last edited by DOS386 on 24 Jan 2009, 03:15; edited 6 times in total
Post 29 Jul 2008, 06:45
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 29 Jul 2008, 09:13
a cracking challenge?

Like you said here: http://board.flatassembler.net/topic.php?p=80082#80075
Seems to be 16-bit code Sad
erm, I'll give a wild guess because on 64-bit systems this won't run.

1) \/\/ is nice ASCII-art Smile
2) MOVNTQ is some illusion-making comment - what is so non-temporal about 0???
3) is Bra a reference to womens' accessories ^o)

Anyway:

GUESS= your trying to count some interesting files from C-drive root ... and maybe subdirectory named SUB?
Post 29 Jul 2008, 09:13
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
AxelDominatoR



Joined: 11 Aug 2004
Posts: 12
AxelDominatoR 29 Jul 2008, 13:44
I gave you code a rapid look.
From what I have understood, it tries to access the various files managing slashes/backslashes. It prints an happy smiley on good file access and a sad one on access failed. It displays file handles number with n * and good file closure with C.
Then at the end you make a test for a 64 bit "long seek", right?
Post 29 Jul 2008, 13:44
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 29 Jul 2008, 14:14
It seems to test slashes in file handling? If I make a C:\blah.xxx all 6 blah.xxx's get smiley face. Same with C:\sub\blah.yyy

Some kind of self-modifying code?

Why have pop defined as pope?


Madis731: It looks like BRA stands for bracket "(" or ")" for smiley or sad face.


Description:
Filesize: 15.94 KB
Viewed: 8943 Time(s)

freedos.GIF



_________________
----> * <---- My star, won HERE
Post 29 Jul 2008, 14:14
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 30 Jul 2008, 13:43
windwakr wrote:

Why have pop defined as pope?


I think I know the answer to that. I've been thinking myself about aligning to same-length syntaxes (that sentence came out wierd) but here is a better explanation:
Code:
push rax rbx rcx
pop rcx rbx rax ;you can align by adding a space here

push rax rbx rcx
popp rcx rbx rax ; this looks better BUT...

psh rax rbx rcx
pop rcx rbx rax ;...resembles more the other mnemonics:
mov
sub
not
xor
;etc.
    

but maybe he's just joking there Razz

OT:
What I've also thought about is making either push or pop reversed so I can easily copy-paste my push or pop line. Extremely time-expensive manual work:
Code:
push rax rbx rcx rdx rsi rdi rbp r8 r9 r10 r11 r12 r13 r14 r15
pop rax rbx rcx rdx rsi rdi rbp r8 r9 r10 r11 r12 r13 r14 r15 ;!!! modified pop
    

_________________
My updated idol Very Happy http://www.agner.org/optimize/
Post 30 Jul 2008, 13:43
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Shahada



Joined: 25 Jul 2008
Posts: 77
Shahada 01 Aug 2008, 09:45
You seems to check about operating system accept more slash and if it accept boths back and forward slash in file operation. Isn't it?
Post 01 Aug 2008, 09:45
View user's profile Send private message Reply with quote
Shahada



Joined: 25 Jul 2008
Posts: 77
Shahada 01 Aug 2008, 20:04
Sory windwakr I see not your solution before I answer. Sad
Post 01 Aug 2008, 20:04
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 01 Aug 2008, 20:14
DOS386: You gonna tell us exactly what it does now?

_________________
----> * <---- My star, won HERE
Post 01 Aug 2008, 20:14
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 23 Aug 2008, 07:13
> You gonna tell us exactly what it does now?

YES.

Madis731 wrote:
Like you said here: Seems to be 16-bit code Sad


But in my code the use16 is visible just 5 lines below top of post. Why the sad smiley ?

Quote:
3) is Bra a reference to womens' accessories ^o)


YES.

AxelDominatoR wrote:

Quote:
I gave you code a rapid look.
From what I have understood, it tries to access the various files managing slashes/backslashes. It prints an happy smiley on good file access and a sad one on access failed. It displays file handles number with n * and good file closure with C.
Then at the end you make a test for a 64 bit "long seek", right?


Very good Smile

> It seems to test slashes in file handling?

YES.

> Some kind of self-modifying code?

NO.

> Why have pop defined as pope?

http://board.flatassembler.net/topic.php?p=73815#73815

THE SOLUTION :

It tests the ability of DOS kernel to put up with forward slashes (FreeDOS and EDR-DOS both good), and multiple slashes (FreeDOS: good | EDR-DOS: bad).

Also it tests the new 64-bit seek (FreeDOS: not yet supported | EDR-DOS: BUG , but promised to get fixed)

Challenge closed - but don't cry, I'll create a new one occasionally Idea

_________________
Bug Nr.: 12345

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

Status: Closed: NOT a Bug
Post 23 Aug 2008, 07:13
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 11 Jan 2009, 10:03
.
.
This one exposes the "no-error-handling-at-all-BUG" in INT $21 / AX=$7142 in EDR-DOS (still present in 2009-Jan release)
.
.

Code:
; FASM (R) code | 359 Bytes
; Tests bugged handling of INT $21 / AX = $42 $7142 $7342 $7542 $7742
; in EDR-DOS and FreeDOS
; (CL) 2009-01-20 | Abuse at your own risk !!!

define pope  pop
define popef popf

format binary as "COM"
use16
org $0100

; [80286]

         ; Welcome

         call  sseol
         call  @f
         db    '(CL) 2009 - Hi seeker (optional file "XX" to test)',0
myxx:    db    'XX',0
@@:      pope  si
         call  ssprint
         call  ssdeol

         ; Announce open

         mov   dx, 'Op'
         call  ssdchar
         call  ssspc

         ; Open + pick hen

         mov   dx, myxx
         mov   ax, $3D00      ; Open stuff
         int   $21            ; Try to open
         call  callres
         jnc   short @f       ; OK
         mov   ax, $FFFE      ; Invalid
@@:      mov   bp, ax         ; Hen
         call  ssdeol

         ; Boast with hen

         mov   dx, 'h='
         call  ssdchar
         mov   ax, bp         ; Hen
         call  sshex16
         call  ssdeol

         ; Seek

         mov   ax, $4200      ; Original old seek
         push  ax
         call  sshex16
         call  ssspc
         pope  ax             ; Origin type in AL is "0" - absolute
         mov   bx, bp         ; Hen
         mov   cx, 0          ; Position in CX:DX (CX is high) | out DX:AX
         mov   dx, 1          ; Input position is 1
         int   $21
         call  callres
         call  ssdeol

         mov   ah, $71
         call  bigseek

         mov   ah, $73
         call  bigseek

         mov   ah, $75
         call  bigseek

         mov   ah, $77
         call  bigseek

         ; Announce close

         mov   dx, 'Cl'
         call  ssdchar

         ; Close

         mov   bx, bp         ; Hen
         mov   ah, $3E        ; Close it now, enough is enough !!!
         int   $21
         jmp   zz
         ;-------

; SUB

bigseek:
         mov   al, $42        ; AH = $71 or $73 or $75 or $77
         push  ax
         call  sshex16        ; Boast with AX
         call  ssspc
         mov   di, $0100      ; Buffer
         mov   dx, di         ; For INT also
         cld
         xor   ax, ax         ; MOVNTQ AX, 0
         mov   cx, 8
         rep   stosd          ; Clear 16 bytes, CL==0 Origin type
         clc                  ; !!!
         pope  ax             ; Subfunc of INT $21
         mov   bx, bp         ; Hen, if ever valid ...
         int   $21
         call  callres
         jmp   ssdeol
         ;-----------

; SUB

callres:
         pushf
         pusha
         push  ax
         mov   dl, 0
         adc   dl, $30
         push  dx
         mov   dx, 'C='
         call  ssdchar
         pope  dx
         call  sschar         ; Report flag(C)
         call  ssspc
         mov   dx, 'A='
         call  ssdchar
         pope  ax
         call  sshex16        ; Report AX
         call  ssspc
         popa
         popef
         ret
         ;----

; SUB Write HEX16 | input in AX | trashes all

sshex16: mov   cl, 4
yy:      mov   dl, ah         ; DL <- AH move 8 bits, only 4 useful
         shl   ax, 4
         shr   dl, 4
         add   dl, $30
         cmp   dl, $3A
         jb    @f             ; "b" : below unsigned | OK, a number
         add   dl, 7
@@:      push  ax
         push  cx
         call  sschar
         pope  cx
         pope  ax
         dec   cl
         jnz   yy
         ret
         ;----

ssspc:   mov   dl, 32
         jmp   sschar
         ;-----------

ssdeol:  call  sseol
         ; and pass

sseol:   mov   dx, $0A0D
         ; and pass

ssdchar: push  dx
         call  sschar
         pope  dx
         mov   dl, dh
         ; and pass

sschar:  mov   ah, 2
         int   $21
qq:      ret
         ;----

sssad:   call  @f
         db    " Sad",0
@@:      pope  si
         ; and pass

ssprint: lodsb
         cmp   al, 0
         jz    short qq       ; Stealing a RAT Very Happy
         mov   dl, al
         call  sschar
         jmp   ssprint
         ;------------

; The END of FUN Sad((

zz:      call  ssdeol
         call  @f
         db    'The truth is out',0
@@:      pope  si
         call  ssprint
         call  sssad
         call  ssdeol
         mov   ax, $4C00      ; Exit to DOS
         int   $21
         ;--------

; END.
    


Crying or Very sad


Last edited by DOS386 on 24 Jan 2009, 03:13; edited 1 time in total
Post 11 Jan 2009, 10:03
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 24 Jan 2009, 03:10
Download now (all 3 tests in): download.php?id=4177 4'301 Bytes

Code:
; FASM (R) code | 512 Bytes
; Tests unusable performance of FAT "technology"
; (CL) 2009-01-20  | Abuse at your own risk !!!
; 1.5  GiB = 1'610'612'736 = $6000'0000
; 1.75 GiB = 1'879'048'192 = $7000'0000

define pope  pop
define popef popf

format binary as "COM"
use16
org $0100

; [80286]

         ; Welcome

         call  sseol
         call  @f
         db    '(CL) 2009 - Hi seeker (need file "XX" >=1.75 GiB to test)',0
myxx:    db    'XX',0
@@:      pope  si
         call  ssprint
         call  ssdeol

         ; Open junk

         mov   dx, myxx
         mov   ax, $3D00      ; Open stuff
         int   $21            ; Try to open
         jnc   short aa       ; OK

         ; Bunch of trouble

         call  @f
         db    'Not found',0
@@:      pope  si
         jmp   short gg
         ;-------------

pp0:     call  @f
         db    'We have a problem, dude',0
@@:      pope  si
         jmp   short gg
         ;-------------

bb:      call  @f
         db    'Not bloated enough',0
@@:      pope  si
         ; pass

         ; Finalize trouble

gg:      call  ssprint
         call  sssad
         jmp   zz             ; EOF
         ;-------

         ; OK so far, seek to end AKA "GetFileSizeObsolete"

aa:      mov   bp, ax         ; Hen
         mov   bx, bp         ; Hen
         mov   ax, $4202      ; Original old seek to end
         xor   cx, cx         ; Position in CX:DX (CX is high) -> DX:AX
         xor   dx, dx         ; 0
         int   $21
pp1:     jc    short pp0
         cmp   dx, $7000      ; 1.75 GiB
         jb    short bb       ; Too small

         ; Report what we got

         push  ax             ; LO
         push  dx             ; HI
         call  @f
         db    'Size: $',0
@@:      pope  si
         call  ssprint
         pope  ax
         call  sshex16
         mov   dl, 39         ; "'" apo
         call  sschar
         pope  ax
         call  sshex16
         call  ssdeol

         ; Seek to 0

         mov   bx, bp         ; Hen
         mov   ax, $4200      ; Original old seek back to begin
         xor   cx, cx         ; Position in CX:DX (CX is high) -> DX:AX
         xor   dx, dx         ; 0
         int   $21
pp2:     jc    short pp1

         ; Peek timer

         call  sspt
         push  ax

         ; Do forward run

         mov   cx, 25         ; 25 * 32 MiB = 800 MiB
@@:      stc                  ; Fwd
         call  ssstep
         loop  @b

         pope  dx             ; Start time in DX
         call  sspt           ; Preserves all except AX, AX is end time
         sub   ax, dx         ; Result in AX
         push  ax
         call  @f
         db    ' Fwd time: $',0
@@:      pope  si
         call  ssprint
         pope  ax
         call  sshex16

         ; Isolate text

         call  ssdeol

         ; Seek to 1.5 GiB

         mov   bx, bp
         mov   ax, $4200      ; Original old seek absolute
         xor   dx, dx         ; 0
         mov   cx, $6000      ; Position in CX:DX (CX is high) | 1.5 GiB
         int   $21
         jc    short pp2

         ; Peek timer

         call  sspt
         push  ax

         ; Do back run

         mov   cx, 25         ; 25 * -32 MiB = -800 MiB , starting at 1536 MiB
@@:      clc                  ; Back
         call  ssstep
         loop  @b

         pope  dx             ; Start time in DX
         call  sspt           ; Preserves all except AX, AX is end time
         sub   ax, dx         ; Result in AX
         push  ax
         call  @f
         db    ' Back time: $',0
@@:      pope  si
         call  ssprint
         pope  ax
         call  sshex16

         ; Close

         mov   bx, bp         ; Hen
         mov   ah, $3E        ; Close it now, enough is enough !!!
         int   $21
         jmp   zz
         ;-------

; SUB: Seek step: reading 32 KiB & relative seeking by + or - 32 MiB
; Conmtrolled by flag(C): 1: FWD | 0: BACK

ssstep:  push  cx
         pushf

         ; Read

         mov   bx, bp         ; Hen
         mov   ax, $3F00      ; Read
         mov   cx, $8000      ; How much: 32 KiB (has almost no effect)
         mov   dx, $4000      ; Where: + 16 KiB
         int   $21
         jc    short uu

         ; Seek

         mov   bx, bp         ; Hen
         mov   ax, $4201      ; Original old seek relative
         xor   dx, dx         ; 0

         mov   cx, $0200      ; Distance in CX:DX (CX is high) | 32 MiB
         popef
         jc    @f
         neg   cx             ; 0 - $0200 = $FE00
@@:
         int   $21            ; Do seek
         jc    short uu

         mov   dl, 46         ; "." dot only on success
         call  sschar

uu:      pope cx
         ret
         ;----

; SUB: Peek timer into AX | Preserves all except AX and flags

sspt:    push  es
         xor   ax, ax         ; MOVNTQ AX, 0
         mov   es, ax         ; MOVNTQ ES, 0
         mov   ax, [es:$046C] ; There are 16 upper bits ... ignore the junk
         pope  es
         ret
         ;----

; SUB Write HEX16 | input in AX | trashes all

sshex16: mov   cl, 4
yy:      mov   dl, ah         ; DL <- AH move 8 bits, only 4 useful
         shl   ax, 4
         shr   dl, 4
         add   dl, $30
         cmp   dl, $3A
         jb    @f             ; "b" : below unsigned | OK, a number
         add   dl, 7
@@:      push  ax
         push  cx
         call  sschar
         pope  cx
         pope  ax
         dec   cl
         jnz   yy
         ret
         ;----

ssspc:   mov   dl, 32
         jmp   sschar
         ;-----------

ssdeol:  call  sseol
         ; and pass

sseol:   mov   dx, $0A0D
         ; and pass

ssdchar: push  dx
         call  sschar
         pope  dx
         mov   dl, dh
         ; and pass

sschar:  mov   ah, 2
         int   $21
qq:      ret
         ;----

sssad:   call  @f
         db    " Sad",0
@@:      pope  si
         ; and pass

ssprint: lodsb
         cmp   al, 0
         jz    short qq       ; Stealing a RAT Very Happy
         mov   dl, al
         call  sschar
         jmp   ssprint
         ;------------

; The END of FUN Sad((

zz:      call  ssdeol
         call  @f
         db    'The truth is out',0
@@:      pope  si
         call  ssprint
         call  sssad
         call  ssdeol
         mov   ax, $4C00      ; Exit to DOS
         int   $21
         ;--------

; END.
    


Enjoy Very Happy
Post 24 Jan 2009, 03:10
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.