Page 2 of 2

Re: How do I move data from a pointer?

Posted: Tue Dec 21, 2010 8:23 am
by Combuster
Epic fail.

Equivalent code:

Code: Select all

   mov cl, 8
   mov ah, 0x0e
   mov al, cl
   int 0x10 ; print special character 8
   db 0x48

Re: How do I move data from a pointer?

Posted: Tue Dec 21, 2010 10:17 am
by JamesM

Code: Select all

unsigned short getea(unsigned char rmval, unsigned char mod) {
         switch (mod) {
                case 0:
                     if (rmval==0) return((*segptr<<4)+bx+si);
                        else if (rmval==1) return((*segptr<<4)+bx+di);
                        else if (rmval==2) return((*segptr<<4)+bp+si);
                        else if (rmval==3) return((*segptr<<4)+bp+di);
                        else if (rmval==4) return((*segptr<<4)+si);
                        else if (rmval==5) return((*segptr<<4)+di);
                        else if (rmval==6) return((*segptr<<4)+disp);
                        else if (rmval==7) return((*segptr<<4)+bx);
                     break;
                case 1:
You know you can nest switch statements, right?

Code: Select all

mov cl, PointTo
   mov ah, 0x0e
   mov al, cl
   int 0x10
   
PointTo:
   db 'H'
Things can assemble which will not run correctly. You're moving a 16-bit pointer into an 8-bit register, silently truncating the top 8 bits which the BIOS will then try and dereference. What are you even trying to achieve with that code?!

Re: How do I move data from a pointer?

Posted: Tue Dec 21, 2010 12:14 pm
by quok
Locking this before it goes any farther, and admittedly in a half hearted attempt to help the OP save some face with the rest of the forum.