Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.msdos.programmer > #4045
| From | Mateusz Viste <mateusz@xyz.invalid> |
|---|---|
| Newsgroups | comp.os.msdos.programmer |
| Subject | Re: assembly: mov a memory word into register |
| Date | 2021-11-12 18:40 +0100 |
| Organization | . . . |
| Message-ID | <20211112184026.2113fa04@mateusz.lan> (permalink) |
| References | <20211112143535.05889a42@mateusz.lan> <smm65c$2vd$1@gioia.aioe.org> |
2021-11-12 at 17:53 +0100, Herbert Kleebauer wrote:
> On 12.11.2021 14:35, Mateusz Viste wrote:
>
> > I somehow got stuck on a simple quest: copying a word from memory
> > into a register. Here's what I do:
> >
> > void myfunc(char *buff) {
> > _asm {
> > mov ax, [buff]
> > }
> > }
> >
> > This is inline assembly within OpenWatcom. My understanding so far
> > was that:
> >
> > mov ax, buff ; copies buff (pointer) into AX
>
> > mov ax, [buff] ; copies *buff (first word at memory location)
> > into AX
>
> There is no such x86 instruction. For indirect addressing you have to
> use a register.
That is correct indeed, thanks. I have been confused by what "buff"
truly is. It is still weird that buff and [buff] are the same, but
that's certainly due to the magic introduced by the C compiler to
reference C variables within the inline assembly block.
To illustrate/understand the "issue", I wrote a little test program.
; print first char of cmdline tail
cpu 8086
org 0x100
; does not work (prints the character 0x82)
mov ah, 2
mov dl, [buff]
int 0x21
; works (prints the character at location 0x82)
mov ah, 2
mov dl, [0x82]
int 0x21
; game over
mov ax, 0x4c00
int 0x21
buff dw 0x82
Mateusz
Back to comp.os.msdos.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
assembly: mov a memory word into register Mateusz Viste <mateusz@xyz.invalid> - 2021-11-12 14:35 +0100
Re: assembly: mov a memory word into register "Kerr-Mudd, John" <admin@127.0.0.1> - 2021-11-12 16:52 +0000
Re: assembly: mov a memory word into register Herbert Kleebauer <klee@unibwm.de> - 2021-11-12 17:53 +0100
Re: assembly: mov a memory word into register Mateusz Viste <mateusz@xyz.invalid> - 2021-11-12 18:40 +0100
Re: assembly: mov a memory word into register Herbert Kleebauer <klee@unibwm.de> - 2021-11-12 19:19 +0100
Re: assembly: mov a memory word into register Mateusz Viste <mateusz@xyz.invalid> - 2021-11-12 20:07 +0100
Re: assembly: mov a memory word into register Herbert Kleebauer <klee@unibwm.de> - 2021-11-12 22:18 +0100
Re: assembly: mov a memory word into register rridge@csclub.uwaterloo.ca (Ross Ridge) - 2021-11-15 16:53 +0000
Re: assembly: mov a memory word into register Rod Pemberton <noemail@basdxcqvbe.com> - 2021-11-14 20:53 -0500
Re: assembly: mov a memory word into register Mateusz Viste <mateusz@xyz.invalid> - 2021-11-15 09:31 +0100
Re: assembly: mov a memory word into register Herbert Kleebauer <klee@unibwm.de> - 2021-11-15 12:10 +0100
Re: assembly: mov a memory word into register Mateusz Viste <mateusz@xyz.invalid> - 2021-11-15 13:02 +0100
csiph-web