From: king621@nospicedham.comcast.net   
      
   On 04/24/2018 07:08 PM, Rod Pemberton wrote:   
   > On Tue, 24 Apr 2018 16:20:47 -0700   
   > bilsch wrote:   
   >   
   >> On 04/24/2018 04:04 AM, Bartc wrote:   
   >>> On 24/04/2018 10:48, bilsch wrote:   
   >   
   >>>> The boot sector jumps to this code.   
   >>>> It should print junk6789 but prints only j   
   >>>> Why it not print junk6789 ? TIA. Bill S.   
   >>>   
   >>>>   
   >>>> pbuf times 80 db 0   
   >>>> string db 'junk'   
   >>>   
   >>>> mov si,pbuf   
   >>>> mov di,string   
   >>>> lup8: mov al,[di]   
   >>>> mov byte[si],al   
   >>>> inc si   
   >>>> inc di   
   >>>> cmp di,4   
   >>>> jbe lup8   
   >>>   
   >>> di starts at label 'string'. Is that address 0? If not then   
   >>> comparing it with 4 looks odd.   
   >>>   
   >>> If string has an address of at least 80 as seems likely, then this   
   >>> will compare false and only one character is copied to the buffer.   
   >>>   
   >>   
   >> Indeed. Here's the fix to the code above. It prints 'junk' but not   
   >> 'junk6789'. My real question is why doesn't it print the 6789 part?   
   >>   
   >> string db 'junk',0   
   >>   
   >> mov si,pbuf   
   >> mov di,string   
   >> lup8: mov al,[di]   
   >> cmp al,0   
   >> jz ovr1   
   >> move byte[si],al   
   >> inc si   
   >> inc di   
   >> jmp lup8   
   >> ovr1:   
   >>   
   >   
   > Your 'junk' loop at 'lup8' already increments 'si' _after_ storing al,   
   > and then you increment 'si' again at 'xo5', but /prior/ to storing 'al'.   
   > So, you've skipped copying a character into one location. Since pbuf   
   > buffer is zero'd initially, you've "inserted" a nul character between   
   > 'junk' and '6789', due to this skip or off-by-one error. Your prstr   
   > routine terminates at nul characters, which then skips everything after   
   > 'junk' since 'junk' is followed by a nul character. I.e., the 'inc si'   
   > at 'xo5' should be below the next instruction.   
   >   
   >   
   > Rod Pemberton   
   >   
   I added 'dec si' at ovr1 and it works now.   
   Good news: this is what was causing my original problem in my real   
   program. I fixed it also by adding a dec si line.   
   Thanks for the help.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|