This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
> >Hii all, >Right now, I'm trying to porting 80x86 code to M68K. >In Intel, there is a function: pokeb(base_addr,offset,data) >and using Borland C Compiler will translated like this : > > /* Assembly Routine to do a pokeb */ > /* bp points at stack */ > /* stack + 0xc = data */ > /* stack + 0xa = register offset from base addr. */ > /* es - set to be segment value (CS) */ > /* si - set to be register offset */ > /* al - data */ > > mov ax,[base_addr] > mov es,ax > mov al,[bp+0x0C] > mov si,[bp+0x0A] > mov es:[si],al > >I'm a high level programmer, and I don't really understand >where this 0x0c and 0x0a come from, and how could in 0x0c >is data, and in 0x0a is register offset?? >Can somebody explain step by step what the assembler >trying to do?? >Is there anybody M68K programmer know any C function to replace >pokeb, peekb function in M68K?? I don't know the 80x86 machine architecture or 80x86 C calling interface, but I'll make a few guesses. It looks like pokeb() takes a variable holding a segment number, an offset into that segment, and data to write into memory ("poke"). > mov ax,[base_addr] > mov es,ax Loads the content of the "base_address" variable into register es. > mov al,[bp+0x0C] Loads the value of "data" which is being passed on the stack at a stack offset of 0x0c into register al. > mov si,[bp+0x0A] Loads the value of "offset" which is being passed on the stack at a stack offset of 0x0a into register si. > mov es:[si],al Stores the data in register al into memory at the location pointed to by the segment in register es and the offset in register si. Since the m68k is not a segmented memory machine, the pokeb() function wouldn't need a base and offset, but in the interest of following the same model, an m68k routine could look like: /* pokeb(char *base_addr, int offset, char data) */ .global pokeb pokeb: move.l 4(%sp),%a0 /* get base_addr */ add.l 8(%sp),%a0 /* add offset */ move.b 15(%sp),(%a0) /* move data byte */ rts Art