Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 4,600 of 4,675    |
|    Tavis Ormandy to Paul Edwards    |
|    Re: ss and lea on 8086    |
|    24 Jun 23 14:52:17    |
      From: taviso@nospicedham.gmail.com              [I've rearranged your code to intermix code with assembly]              On 2023-06-24, Paul Edwards wrote:       > void dumplong(unsigned long x)       > _dumplong:       > push bp       > mov bp,sp              Note: Making space for locals, not an offset.              > char buf[9];       > sub sp,OFFSET L04604              Note: Loading far pointer to "0123..." into z              > char *z = "0123456789abcdef";       > mov ax,OFFSET L03767       > mov dx,ds       > mov WORD PTR -16[bp],ax       > mov WORD PTR -14[bp],dx              > y = 0;       > mov WORD PTR ?y@?1??dumplong@@9@9,OFFSET 0              > buf[0] = 'P';       > buf[1] = 'P';       > buf[2] = 'P';       > buf[3] = 'P';       > mov BYTE PTR -12[bp],OFFSET 80       > mov BYTE PTR -11[bp],OFFSET 80       > mov BYTE PTR -10[bp],OFFSET 80       > mov BYTE PTR -9[bp],OFFSET 80              > buf[3-y] = 'R';       > mov ax,OFFSET 3       > sub ax,WORD PTR ?y@?1??dumplong@@9@9       > lea bx,WORD PTR -12[bp]       > add bx,ax       > mov BYTE PTR ss:[bx],OFFSET 82              > buf[4] = 'P';       > mov BYTE PTR -8[bp],OFFSET 80              > buf[4+y] = 'S';       > mov ax,WORD PTR ?y@?1??dumplong@@9@9       > add ax,OFFSET 4       > lea bx,WORD PTR -12[bp]       > add bx,ax       > mov BYTE PTR ss:[bx],OFFSET 83              > buf[5] = 'P';       > buf[6] = 'P';       > buf[7] = 'P';       > mov BYTE PTR -7[bp],OFFSET 80       > mov BYTE PTR -6[bp],OFFSET 80       > mov BYTE PTR -5[bp],OFFSET 80       >       >       > I've been looking at this for hours.       >       > Unless I've somehow stuffed up the test, this data is       > all being set to 'P'.              I don't follow, you set buf[3] to 'R' (shows as OFFSET 82 in the       disassembly) and buf[4] to 'S'.              >       > Regardless of whether I do a subtraction or an addition       > (of 0), the data is not changed.              You don't really explain what problem you're seeing, here is a       line-by-line:              > buf[3-y] = 'R';              > mov ax,OFFSET 3 ; ax = 3       > sub ax,WORD PTR ?y@?1??dumplong@@9@9 ; ax -= y              So now ax is 3-y              > lea bx,WORD PTR -12[bp] ; bx = &buf[0]       > add bx,ax ; bx += ax              So now bx is &buf[3-y]              > mov BYTE PTR ss:[bx],OFFSET 82 ; *bx = 'R'              Set *bx = 'R', isn't that correct?              Tavis.              --        _o) $ lynx lock.cmpxchg8b.com        /\\ _o) _o) $ finger taviso@sdf.org       _\_V _( ) _( ) @taviso              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca