Assuming "real mode" programming for 8086, then we will use the general-purpose register AX (16-bit), the general-purpose register and index register BX (16-bit), and the segment register ES (16-bit).
PS. ES = "extra segment"
int x=100, y=200;
int far *ptx;
int far *pty;
assuming the instructions have already been executed:
ptx = &x;
pty = (int *)malloc(sizeof(int));
my question is on how to encode the following paragraphs in Assembly:
isso aqui parece razoavelmente fácil: cada ponteiro far é composto por 2 bytes de
segmento e dois bytes de offset
a) ptx = pty
; offset
MOV AX, word ptr pty
MOV word ptr ptx, AX
; segmento
MOV AX, word ptr pty+2
MOV word ptr ptx+2, AX
aqui tem que usar o registrador ES
b) *ptx = *pty
; carrega pty em ES:BX
LES BX, pty
; carrega *pty em AX
MOV AX, word ptr ES:[BX]
; carrega ptx em ES:BX
LES BX, ptx
; salva AX em *ptx
MOV word ptr ES:[BX], AX
It is possible to have some syntax problem, we would have to run the MASM 17 bits to check this, but overall that’s it.
"int far *" no longer exists, unless you are programming for MS-DOS...
– zentrunix
we use dosbox to program, with turboC
– IanMoone
use the Debugger to see the Assembly instructions, or in the compilation use the option (which I don’t know what it is) to generate an Assembly listing...I don’t remember the details, but I know the two things above are possible
– zentrunix
the problem is that this is a test exercise. I’m going to do it frequently and I needed to know this, but I have no way of knowing
– IanMoone
I have to do that code in writing, not on the computer
– IanMoone
What architecture are you using? x86 or MIPS?
– H.Lima
We use 8086 processor Assembly
– IanMoone