Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

It's documented in The Book, somewhere... -- Larry Wall in <10502@jpl-devvax.JPL.NASA.GOV>


programming / comp.lang.asm.x86 / Re: Isn't this anomalous behavior? What can I do?

SubjectAuthor
* Isn't this anomalous behavior? What can I do?bilsch01
+* Re: Isn't this anomalous behavior? What can I do?rick.c.hodgin
|`- Re: Isn't this anomalous behavior? What can I do?Kerr-Mudd, John
`* Re: Isn't this anomalous behavior? What can I do?s dubrovich
 `- Re: Isn't this anomalous behavior? What can I do?bilsch01

1
Subject: Isn't this anomalous behavior? What can I do?
From: bilsch01
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Thu, 26 Dec 2019 09:44 UTC
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: king...@nospicedham.comcast.net (bilsch01)
Newsgroups: comp.lang.asm.x86
Subject: Isn't this anomalous behavior? What can I do?
Date: Thu, 26 Dec 2019 01:44:16 -0800
Organization: A noiseless patient Spider
Lines: 75
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <qu1vdi$squ$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="a907cd3894da2cf2280f378f40d61af6";
logging-data="32106"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/W+yo+/lX5mCa2UyX/rgyJ/QA82j/9iH8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.2.2
Cancel-Lock: sha1:BadphLWdQf7b/ZGhk/MRnA8KYhc=
View all headers
The code below writes 5 words to memory at 0x37000. I verified the words are there using code not shown (for simplicity), but it's easy to see that the words should be there. After that the 2 lines:


mov si,3
    mov ax,word[fs:si]

should put dd66 in ax register but instead it puts a byte from each of 2 other words in ax, specifically 77bb. The routine at the end prints the result 77BB when it should print DD66.

I have a situation where I really need something like this to work. How can I do it?   TIA.   Bill S.

bits 16
org 0x0000

SECTION  .data

fat5 dw 0xaa99,0xbb88,0xcc77,0xdd66,0xee55,0xff44

SECTION  .text

push 0
pop ss
mov sp,0x7aff
push 0x1000
pop ds
push 0xb800
pop es

; write 5 words to mem at 0x37000

push 0x3700
pop fs
mov di,0
mov si,fat5
mov cx,5
fatlu: mov ax,word[ds:si]
mov word[fs:di],ax
add si,2
add di,2
loop fatlu

; here's the test

mov si,3
    mov ax,word[fs:si]

push ax
jmp vuhex ;prints 77BB
;should be DD66

; prints 4 hex digits from stack

vuhex: pop ax ;4 hex digits
mov di,3832 ;l.r. corner
mov cx,4 ;;# of hex digits
vh01: rol ax,4 ;hi digit on right
push ax ;push rol'd ax
and al,0x0f ;;masks right digit
add al,'0' ;0 thru 9
cmp al,'9'
jbe vh02
add al,0x7 ;A thru F
vh02: mov byte[es:di],al
  inc di
mov byte[es:di],0x0f ;blk/wht
inc di
pop ax ;pop rol'd ax
loop vh01

jmp $



Subject: Re: Isn't this anomalous behavior? What can I do?
From: rick.c.h...@nospicedham.gmail.com
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Thu, 26 Dec 2019 10:30 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: rick.c.h...@nospicedham.gmail.com
Newsgroups: comp.lang.asm.x86
Subject: Re: Isn't this anomalous behavior? What can I do?
Date: Thu, 26 Dec 2019 02:30:31 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 134
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <9fac6203-a97a-4e41-9954-a3ade5bf9026@googlegroups.com>
References: <qu1vdi$squ$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Thu, 26 Dec 2019 10:30:32 +0000
Injection-Info: reader02.eternal-september.org; posting-host="a907cd3894da2cf2280f378f40d61af6";
logging-data="12193"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19T+0994IkP2TLEnL0cj7XX97rF+V5ulnw="
User-Agent: G2/1.0
Cancel-Lock: sha1:FnJc955LgAB09lCyC/YvurX8cdU=
View all headers
On Thursday, December 26, 2019 at 4:53:21 AM UTC-5, bilsch01 wrote:
The code below writes 5 words to memory at 0x37000. I verified the words
are there using code not shown (for simplicity), but it's easy to see
that the words should be there. After that the 2 lines:

mov si,3
    mov ax,word[fs:si]

should put dd66 in ax register but instead it puts a byte from each of 2
other words in ax, specifically 77bb. The routine at the end prints the
result 77BB when it should print DD66.

I have a situation where I really need something like this to work. How
can I do it?   TIA.   Bill S.

bits 16
org 0x0000

SECTION  .data

fat5 dw 0xaa99,0xbb88,0xcc77,0xdd66,0xee55,0xff44

SECTION  .text

push 0
pop ss
mov sp,0x7aff
push 0x1000
pop ds
push 0xb800
pop es

; write 5 words to mem at 0x37000

push 0x3700
pop fs
mov di,0
mov si,fat5
mov cx,5
fatlu: mov ax,word[ds:si]
mov word[fs:di],ax
add si,2
add di,2
loop fatlu

You can use ds:[si] and es:[di] and some CPU features if you
want:

        push    0x1000
        pop     ds
        push    0x3700
        pop     es

        mov     si,fat5
        xor     di,di
        mov     cx,5

       ; May need to set the direction flag here
    ==> rep     movsw

The one line removes several lines of loop code, provided you
are able to use ds: and es: instead of ds: and fs:.

; here's the test

mov si,3
    mov ax,word[fs:si]

push ax
jmp vuhex ;prints 77BB
;should be DD66

; prints 4 hex digits from stack

vuhex: pop ax ;4 hex digits
mov di,3832 ;l.r. corner
mov cx,4 ;;# of hex digits
vh01: rol ax,4 ;hi digit on right
push ax ;push rol'd ax
and al,0x0f ;;masks right digit
add al,'0' ;0 thru 9
cmp al,'9'
jbe vh02
add al,0x7 ;A thru F
vh02: mov byte[es:di],al
  inc di
mov byte[es:di],0x0f ;blk/wht
inc di
pop ax ;pop rol'd ax
loop vh01

jmp $

Can you run this code in DOS and verify it's working there?
You can use a debugger to assist you, and it won't matter if
you destroy your runtime environment in DOS because you can
just reboot once you get what information you need from the
debugger.  I used to do things like this in the CodeView 3.x
debugger as it was faster than the 4.x series.

And then for my OS project, I wrote a tiny boot-time debugger.
It was essentially two 64 KB modules, one handling the debugger
logic, the other handling the disassembler.

I added some extra code at the start of my 512 KB boot sector
to read in the debugger and disassembler, each which existed
at a fixed location on disk, and read into a fixed locations
in memory.  After loading, I'd call the setup function and it
would hook into the appropriate interrupt vectors, and then
return and then I continue to boot up like normal.

It added about 70 bytes of code to my boot sector, but then I
had a full debugger available at boot time.  I could single-
step through my code, examine memory, alter memory, etc.

It only worked in 16-bit mode, as after I entered 32-bit mode
I had my own protected mode kernel debugger available, and
could use that.

I recommend finding / creating something like that to help you
out with all of your boot-time assembly needs.  The real-mode
debugger I wrote was able to be run and tested in DOS as a .COM
file using a custom loader to simulate the boot-time load.  I
used it to debug itself at various times. :-)

-----
I have the source code for my debugger if you're interested.
I called it xDebug.  It was written entirely in MASM 6.11d.  I
can put it up on my website if you'd like to download it.  If
so, let me know.

--
Rick C. Hodgin



Subject: Re: Isn't this anomalous behavior? What can I do?
From: s_dubrov...@nospicedham.yahoo.com
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Thu, 26 Dec 2019 16:29 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: s_dubrov...@nospicedham.yahoo.com
Newsgroups: comp.lang.asm.x86
Subject: Re: Isn't this anomalous behavior? What can I do?
Date: Thu, 26 Dec 2019 08:29:21 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 103
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <c9baf825-fc49-4e65-bee3-06286c4bd28e@googlegroups.com>
References: <qu1vdi$squ$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Thu, 26 Dec 2019 16:29:21 +0000
Injection-Info: reader02.eternal-september.org; posting-host="a907cd3894da2cf2280f378f40d61af6";
logging-data="23286"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CydYZpTdRMdG9qk75VbQp/DiglKFNKp8="
User-Agent: G2/1.0
Cancel-Lock: sha1:VwHCeOkLT+lPFpMKglhfki3Q2rU=
View all headers
On Thursday, December 26, 2019 at 3:53:21 AM UTC-6, bilsch01 wrote:
The code below writes 5 words to memory at 0x37000. I verified the words
are there using code not shown (for simplicity), but it's easy to see
that the words should be there. After that the 2 lines:


mov si,3
    mov ax,word[fs:si]

should put dd66 in ax register but instead it puts a byte from each of 2
other words in ax, specifically 77bb. The routine at the end prints the
result 77BB when it should print DD66.

I have a situation where I really need something like this to work. How
can I do it?   TIA.   Bill S.

bits 16
org 0x0000

SECTION  .data

fat5 dw 0xaa99,0xbb88,0xcc77,0xdd66,0xee55,0xff44

SECTION  .text

push 0
pop ss
mov sp,0x7aff
push 0x1000
pop ds
push 0xb800
pop es

; write 5 words to mem at 0x37000

push 0x3700
pop fs
mov di,0
mov si,fat5
mov cx,5
fatlu: mov ax,word[ds:si]
mov word[fs:di],ax
add si,2
add di,2
loop fatlu

; here's the test

mov si,3
    mov ax,word[fs:si]

push ax
jmp vuhex ;prints 77BB
;should be DD66

; prints 4 hex digits from stack

vuhex: pop ax ;4 hex digits
mov di,3832 ;l.r. corner
mov cx,4 ;;# of hex digits
vh01: rol ax,4 ;hi digit on right
push ax ;push rol'd ax
and al,0x0f ;;masks right digit
add al,'0' ;0 thru 9
cmp al,'9'
jbe vh02
add al,0x7 ;A thru F
vh02: mov byte[es:di],al
  inc di
mov byte[es:di],0x0f ;blk/wht
inc di
pop ax ;pop rol'd ax
loop vh01

jmp $

SECTION  .data

fat5 dw 0xaa99,0xbb88,0xcc77,0xdd66,0xee55,0xff44

;; prints 77BB, should be DD66

;; fat5: db 99h, 0AAh, 88h, [0BBh, 77h], 0CCh, {66h, 0DDh}, 55h, 0EEh, 44h, 0FFh

;; SI = 3 points to [nnnnh], as db 99h is at index (offset) 0

'[]' brackets the actual result
'{}' brackets the desired result

SECTION  .text

; mov si, 3
; mov ax, word[fs:si]

;; SI needs to be a word index (offset), 3*2, to point to {nnnnh}
;; SI = 0000h points to byte 99h, plus 6 then points to the low order byte 66h,
;; the high ordered byte is DDh.
;; The correction is:
;;
;; mov si, 3*2

Steve



Subject: Re: Isn't this anomalous behavior? What can I do?
From: bilsch01
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Fri, 27 Dec 2019 09:08 UTC
References: 1 2
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: king...@nospicedham.comcast.net (bilsch01)
Newsgroups: comp.lang.asm.x86
Subject: Re: Isn't this anomalous behavior? What can I do?
Date: Fri, 27 Dec 2019 01:08:59 -0800
Organization: A noiseless patient Spider
Lines: 108
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <qu4hnc$1le$1@dont-email.me>
References: <qu1vdi$squ$1@dont-email.me>
<c9baf825-fc49-4e65-bee3-06286c4bd28e@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="e10a5b0ef98b322de2ac2b0c152bd752";
logging-data="3163"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+mvGGz8qRREW1oYN6p5p6ys3zpjFJ12sA="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.2.2
Cancel-Lock: sha1:fnbKlHyrY8ZMjwwmKFqif4c42vY=
View all headers
On 12/26/19 8:29 AM, s_dubrovich@nospicedham.yahoo.com wrote:
On Thursday, December 26, 2019 at 3:53:21 AM UTC-6, bilsch01 wrote:
The code below writes 5 words to memory at 0x37000. I verified the words
are there using code not shown (for simplicity), but it's easy to see
that the words should be there. After that the 2 lines:


mov si,3
     mov ax,word[fs:si]

should put dd66 in ax register but instead it puts a byte from each of 2
other words in ax, specifically 77bb. The routine at the end prints the
result 77BB when it should print DD66.

I have a situation where I really need something like this to work. How
can I do it?   TIA.   Bill S.

bits 16
org 0x0000

SECTION  .data

fat5 dw 0xaa99,0xbb88,0xcc77,0xdd66,0xee55,0xff44

SECTION  .text

push 0
pop ss
mov sp,0x7aff
push 0x1000
pop ds
push 0xb800
pop es

; write 5 words to mem at 0x37000

push 0x3700
pop fs
mov di,0
mov si,fat5
mov cx,5
fatlu: mov ax,word[ds:si]
mov word[fs:di],ax
add si,2
add di,2
loop fatlu

; here's the test

mov si,3
     mov ax,word[fs:si]

push ax
jmp vuhex ;prints 77BB
;should be DD66

; prints 4 hex digits from stack

vuhex: pop ax ;4 hex digits
mov di,3832 ;l.r. corner
mov cx,4 ;;# of hex digits
vh01: rol ax,4 ;hi digit on right
push ax ;push rol'd ax
and al,0x0f ;;masks right digit
add al,'0' ;0 thru 9
cmp al,'9'
jbe vh02
add al,0x7 ;A thru F
vh02: mov byte[es:di],al
   inc di
mov byte[es:di],0x0f ;blk/wht
inc di
pop ax ;pop rol'd ax
loop vh01

jmp $

SECTION  .data

fat5 dw 0xaa99,0xbb88,0xcc77,0xdd66,0xee55,0xff44

;; prints 77BB, should be DD66

;; fat5: db 99h, 0AAh, 88h, [0BBh, 77h], 0CCh, {66h, 0DDh}, 55h, 0EEh, 44h, 0FFh

;; SI = 3 points to [nnnnh], as db 99h is at index (offset) 0

'[]' brackets the actual result
'{}' brackets the desired result

SECTION  .text

; mov si, 3
; mov ax, word[fs:si]

;; SI needs to be a word index (offset), 3*2, to point to {nnnnh}
;; SI = 0000h points to byte 99h, plus 6 then points to the low order byte 66h,
;; the high ordered byte is DDh.
;; The correction is:
;;
;; mov si, 3*2

Steve


Thanks for your explanation, I realized my mistaken thinking as soon as I saw it.



Subject: Re: Isn't this anomalous behavior? What can I do?
From: Kerr-Mudd, John
Newsgroups: comp.lang.asm.x86
Organization: Dis
Date: Sat, 18 Jan 2020 17:05 UTC
References: 1 2
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: adm...@nospicedham.127.0.01 (Kerr-Mudd, John)
Newsgroups: comp.lang.asm.x86
Subject: Re: Isn't this anomalous behavior? What can I do?
Date: Sat, 18 Jan 2020 16:05:03 -0100
Organization: Dis
Lines: 27
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <op.0ellqpzpd0ninh@anyhost.anywhere>
References: <qu1vdi$squ$1@dont-email.me>
<9fac6203-a97a-4e41-9954-a3ade5bf9026@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="896c78472f2f154cae862c8fed0401c0";
logging-data="16433"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PBiva+RfGJuMl2+g8QJ1AsXucMl7AWNE="
User-Agent: Opera Mail/11.64 (Linux)
Cancel-Lock: sha1:CX2yPARwGXbifA4LkCTu6OLBvWs=
View all headers
On Thu, 26 Dec 2019 09:30:31 -0100, <rick.c.hodgin@nospicedham.gmail.com>  wrote:

On Thursday, December 26, 2019 at 4:53:21 AM UTC-5, bilsch01 wrote:
The code below writes 5 words to memory at 0x37000. I verified the words


[]

I recommend finding / creating something like that to help you
out with all of your boot-time assembly needs.  The real-mode
debugger I wrote was able to be run and tested in DOS as a .COM
file using a custom loader to simulate the boot-time load.  I
used it to debug itself at various times. :-)

-----
I have the source code for my debugger if you're interested.
I called it xDebug.  It was written entirely in MASM 6.11d.  I
can put it up on my website if you'd like to download it.  If
so, let me know.


I'd like to see your xdebug code.

--
Bah, and indeed, Humbug



1
rocksolid light 0.7.2
clearneti2ptor