How do I move data from a pointer?

Programming, for all ages and all languages.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: How do I move data from a pointer?

Post 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
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: How do I move data from a pointer?

Post 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?!
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: How do I move data from a pointer?

Post 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.
Locked