Mail Archives: djgpp/2000/03/15/22:18:42
Great, thanks. It works now. All it needed was the ds:'s
The working code fragment is:
.....
go_up pop dword Zaddra
pop dword Zaddrb
retn
_z80_go nop
byteoff nop
mov byte [ds:_z80_go],0EBh
mov byte [ds:byteoff],013h
jmp short zstart
nop
nop
normop push dword Zaddrb
push dword Zaddra
retn
zstart jmp mf
zend mov byte [ds:_z80_go],090h
mov byte [ds:byteoff],090h
call go_up
.....
Thanks
Alistair
Nate Eldredge (neldredge AT hmc DOT edu) wrote:
: apsh AT ecr DOT mu DOT oz DOT au (Alistair_P SHILTON) writes:
: > I was wondering if it is possible to link self-modifying assembler
: > code to DJGPP. When I try, I get an error message. So I checked
: > the documentation, which says that the code segment is not writable.
: > Is there some way around this?
: >
: > I was planning to use the self-mod to make the code act differently
: > after the first call to it (ie. setup on first call, normal operation
: > on subsequent calls). Now I know that there are other ways of achieving
: > the same end, but I like the concept of self-modding code. Any
: > suggestions?
: The code segment, as addressed via the CS register, is not writable,
: true. This is a feature of the cpu. However, the DS segment
: addresses exactly the same memory (in DJGPP) and is writable. So
: something like this should work:
: movb interrupt_number, %al
: movb %al, modify_here+1
: modify_here:
: int 0x42
: Do be careful to make sure you write it maintainably, though.
: Self-modifying code is dangerous in that respect.
: --
: Nate Eldredge
: neldredge AT hmc DOT edu
- Raw text -