Live data from Hacker News

Win16 Memory Management

os2museum.com

81–86 of 86 posts

Re: Win16 Memory Management

#81
post #74

Earlier quoted context omitted.

None of my college CS courses used programming languages that featured FAR pointers. The above example would cause an infinite loop on Win16's seg:off far memory model, but compiling on Win32 would not cause an infinite loop. Problem is that far pointers only affect the offset, not the segment. So decrementing a 0 value offset would just wrap around to 0xFFFF and the segment would stay the same, so you're going from…

My point is the example code has a generic C bug, not depending on FAR, which is why it should be taught in good C courses. Although the code worked on Win32, and works on most modern C compilers, it's not guaranteed to work on modern C compilers, especially with aggressive optimisation turned on.

I'm not disputing your point.

I'm explaining why the infinite loop actually occurs for those who haven't encountered the problem.

The problem would happen for an array whose beginning element starts at offset 0 for a particular segment and an iteration stop condition that uses ">= 0th element" that scans down the array. I used a 64K allocated array to ensure that the array base would match offset 0.

Problem would also occur if the end of the array aligns with the segment limit and the iteration end condition was "For either situation, the array could be < 64KB. One byte would be sufficient.

Re: Win16 Memory Management

#82

I've been recently working with Classic Mac OS programming[0] and just that memory model (also using dealing with the lack of virtual memory using opaque handles to memory that need to be locked when used) is painful enough[1] - having to deal with segment addressing on top of that does not sound like fun. Thank god for the Motorola 68000! [0]Made an AppleTalk chat client/server https://github.com/kalleboo/GlobalTalk…

I actually found programming on the Mac a lot more painful due to the +/-32K max displacement for BRA/BSR, in MPW you had to manually shuffle blocks of code around to get them into the 32K jump range while in Windows the tools took care of it for you.

Re: Win16 Memory Management

#83
post #76

Earlier quoted context omitted.

Thanks! This is a good idea. I was thinking about typing games and such because he needs to learn words before doing anything useful, but guessing games are definitely fun, too. I can definitely write simple games using QBASIC (was preparing a Dospian on Rpi 4 as his 6 years old birthday gift). Do you have any blog, or any recommendation of books to read for such topics? Maybe I can find some "Programming for kids" b…

To be honest I just picked moments when the kids were bored and wanted daddy time but weren’t buzzing around the house with excess energy to burn. It wasn’t something I specifically planned in advance for. Which meant though whole experience was less like homework for them. As I’m sure you know, sometimes kids just want to experience the stuff their parents do. And when they’re in that kind of mood it’s a lot easier…

Thanks. I think I'll prepare that Dospian box, learn QBASIC myself quickly, and let him try it out gradually. At least he should get some typing and arithmetic "game" experience, even when he is too young for any programming.

Re: Win16 Memory Management

#84

Earlier quoted context omitted.

Thanks! This is a good idea. I was thinking about typing games and such because he needs to learn words before doing anything useful, but guessing games are definitely fun, too. I can definitely write simple games using QBASIC (was preparing a Dospian on Rpi 4 as his 6 years old birthday gift). Do you have any blog, or any recommendation of books to read for such topics? Maybe I can find some "Programming for kids" b…

My parents got me this QBASIC book when I was in elementary school and I remember it being pretty accessible even for very young readers. https://www.abebooks.com/Absolute-Beginners-Guide-Qbasic-Per... Also the Usborne series are classics and a lot of them have been made freely available: https://usborne.com/us/books/computer-and-coding-books

Thank you! That's an expensive book. And looks like all QBASIC books are like that because they were rare to find anyway.

Maybe I'll just leverage my programming experience and build something using online tutorials and a Dosbian box.

Re: Win16 Memory Management

#85

Earlier quoted context omitted.

My parents got me this QBASIC book when I was in elementary school and I remember it being pretty accessible even for very young readers. https://www.abebooks.com/Absolute-Beginners-Guide-Qbasic-Per... Also the Usborne series are classics and a lot of them have been made freely available: https://usborne.com/us/books/computer-and-coding-books

Thank you! That's an expensive book. And looks like all QBASIC books are like that because they were rare to find anyway. Maybe I'll just leverage my programming experience and build something using online tutorials and a Dosbian box.

Haha yeah that's a pretty stupid price. You can get it on eBay for $12 but you'd better bid fast because I'm sure it's going to be a very competitive auction. :)

https://ebay.io/m/zzT1Xf

Re: Win16 Memory Management

#86

I've been recently working with Classic Mac OS programming[0] and just that memory model (also using dealing with the lack of virtual memory using opaque handles to memory that need to be locked when used) is painful enough[1] - having to deal with segment addressing on top of that does not sound like fun. Thank god for the Motorola 68000! [0]Made an AppleTalk chat client/server https://github.com/kalleboo/GlobalTalk…

I actually found programming on the Mac a lot more painful due to the +/-32K max displacement for BRA/BSR, in MPW you had to manually shuffle blocks of code around to get them into the 32K jump range while in Windows the tools took care of it for you.

Early editions of Inside Macintosh implied that code segments couldn't exceed 32 KB, so you'd never run into that situation. (It's not clear whether this was an enforced limitation or just a recommendation.) Instead, developers were expected to divide their applications into multiple CODE segments, using jump table entries in the A5 world to branch between segments.

Later in the operating system's lifecycle, applications typically used a single code segment and a custom loader to apply relocations, allowing them to use JSR within that segment.

Post reply on HN