Discussion:
Isn't this anomalous behavior? What can I do?
(too old to reply)
bilsch01
2019-12-26 10:21:38 UTC
Permalink
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 in l.r. corner

vuhex:
pop ax
mov di,3832
mov cx,4

vh01:
rol ax,4
push ax
and al,0x0f
add al,'0'
cmp al,'9'
jbe vh02
add al,0x7

vh02:
mov byte[es:di],al
inc di
mov byte[es:di],0x0f
inc di
pop ax
loop vh01

jmp $
wolfgang kern
2019-12-26 22:22:41 UTC
Permalink
Post by bilsch01
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
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
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
77BB is correct because of the above mov si,3
will need mov si,6 to see DD66 !
__
wolfgang
Post by bilsch01
; prints 4 hex digits in l.r. corner
pop ax
mov di,3832
mov cx,4
rol ax,4
push ax
and al,0x0f
add al,'0'
cmp al,'9'
jbe vh02
add al,0x7
mov byte[es:di],al
inc di
mov byte[es:di],0x0f
inc di
pop ax
loop vh01
jmp $
Loading...