Bobinas P4G
  • Login
  • Public

    • Public
    • Groups
    • Popular
    • People

Conversation

Notices

  1. Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 04:56:01 UTC Srevin Saju Srevin Saju

    So it suddenly occurs to me that I have a pending #assignment on by Operating Systems course. The assignment seems to be trivial: it is to create a bootloader which prints 'Hello World' on the console. Thought it would be interesting to understand this with some help from my mastodon folks 😄

    #university #operatingsystems #bootloader #nasm #assembly

    PS: future me, if you happen to be reading this post after you have forgotten about this, you can thank me later.

    In conversation Sunday, 29-Jan-2023 04:56:01 UTC from mstdn.io permalink

    Attachments


    1. https://media.mstdn.io/mstdn-media/media_attachments/files/109/652/819/926/360/791/original/3b858db11e34951e.png
    • Bernie (codewiz@mstdn.io)'s status on Sunday, 29-Jan-2023 04:55:50 UTC Bernie Bernie
      in reply to

      @srevinsaju I called them routines, or sometimes subroutines. Procedure is jargon from early procedural languages, such as Pascal.

      In conversation Sunday, 29-Jan-2023 04:55:50 UTC permalink
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 04:55:51 UTC Srevin Saju Srevin Saju
      in reply to
      • Bernie

      Meanwhile, a question, I see `PrintCharacter` which seems to be called a 'procedure' in #assembly (I wrote function call 🤦♂️), but does Assembly have any good style guidelines? For example, preference of snake_case over CameCase, or something like that? and what about indentation? cc @codewiz

      In conversation Sunday, 29-Jan-2023 04:55:51 UTC permalink
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 04:55:52 UTC Srevin Saju Srevin Saju
      in reply to

      Here is the code after a bit of good formatting(?) but at least its more readable. I have a lot of questions, but we will go through it line by line.

      #assembly #bootloader #university

      In conversation Sunday, 29-Jan-2023 04:55:52 UTC permalink

      Attachments


      1. https://media.mstdn.io/mstdn-media/media_attachments/files/109/652/880/209/832/886/original/45bc6884be30cdf8.png
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 04:55:56 UTC Srevin Saju Srevin Saju
      in reply to

      So looking at what has been provided to me, I have this in the material:

      #assembly #bootloader #university

      In conversation Sunday, 29-Jan-2023 04:55:56 UTC permalink

      Attachments


      1. https://media.mstdn.io/mstdn-media/media_attachments/files/109/652/840/014/406/960/original/a3b9d219bcd6d575.png
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 04:59:33 UTC Srevin Saju Srevin Saju
      in reply to

      Re: [BITS 16], the most reasonable explanation I could find was that, when Intel introduced 32-bit CPU, it wanted to maintain backward compatibility with its older 16-bit bootloaders. So it made, the 32-bit mode of processing as a protected on-demand mode. Due to this convention, CPU's start processing the code in 16 bit mode, which then can transfer to 32 bits or 64 bits.

      In conversation Sunday, 29-Jan-2023 04:59:33 UTC permalink
    • Bernie (codewiz@mstdn.io)'s status on Sunday, 29-Jan-2023 04:59:33 UTC Bernie Bernie
      in reply to

      @srevinsaju Which assembler are you using? I've never seen square brackets for assembler.dorextives. The traditional UNIX as as.wellcas gas uses . to introduce directives: https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_7.html

      In conversation Sunday, 29-Jan-2023 04:59:33 UTC permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        Using as - Assembler Directives
    • Bernie (codewiz@mstdn.io)'s status on Sunday, 29-Jan-2023 05:05:10 UTC Bernie Bernie
      in reply to

      @srevinsaju Now you can read the source code of LILO, a PC MBR boooader that was used by Linux distros for several years before GRUB took over:
      https://github.com/iamroot-x86-10/lilo-21.4.4/blob/master/first.S

      In conversation Sunday, 29-Jan-2023 05:05:10 UTC permalink

      Attachments

      1. lilo-21.4.4/first.S at master · iamroot-x86-10/lilo-21.4.4
        Contribute to iamroot-x86-10/lilo-21.4.4 development by creating an account on GitHub.
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 05:05:11 UTC Srevin Saju Srevin Saju
      in reply to

      Looks okay.
      #bootloader #assembly #university

      In conversation Sunday, 29-Jan-2023 05:05:11 UTC permalink

      Attachments


      1. https://media.mstdn.io/mstdn-media/media_attachments/files/109/653/208/691/720/323/original/17e34cd682ae7fd1.png
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 05:05:11 UTC Srevin Saju Srevin Saju
      in reply to

      After several hours of debugging and a hundred open tabs, I present: Hello World in a Bootloader.

      In conversation Sunday, 29-Jan-2023 05:05:11 UTC permalink

      Attachments


      1. https://media.mstdn.io/mstdn-media/media_attachments/files/109/653/664/028/381/028/original/331396bbf45ddb90.png
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 05:05:12 UTC Srevin Saju Srevin Saju
      in reply to

      For our #assignment, we _have_ to use #VirtualBox to run them, and create screenshots of the output of the same.

      In conversation Sunday, 29-Jan-2023 05:05:12 UTC permalink

      Attachments


      1. https://media.mstdn.io/mstdn-media/media_attachments/files/109/653/169/764/247/185/original/8665c9f4dfc79114.png
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 05:05:12 UTC Srevin Saju Srevin Saju
      in reply to

      Looks like we have to choose "Floppy" storage type and choose the boot.img which we created earlier.

      In conversation Sunday, 29-Jan-2023 05:05:12 UTC permalink

      Attachments


      1. https://media.mstdn.io/mstdn-media/media_attachments/files/109/653/188/275/605/759/original/2d5fc5225120931a.png
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 05:05:13 UTC Srevin Saju Srevin Saju
      in reply to

      And I guess I am done, (at least with printing the character 'A').

      #bootloader #boot #assembly

      In conversation Sunday, 29-Jan-2023 05:05:13 UTC permalink

      Attachments


      1. https://media.mstdn.io/mstdn-media/media_attachments/files/109/653/155/477/151/097/original/6fd3851e9ac2a4fe.png
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 05:05:14 UTC Srevin Saju Srevin Saju
      in reply to

      Meanwhile [ORG 0x7c00] also seems to be born out of convention. The BIOS loads the program to the RAM at 0000:7C00 before your program gets a chance to be executed. We _could_ ignore the ORG (aka origin), but your program will assume that its loaded at 0x0000 instead. (But you could choose to add 0x7c00 on every command if you would like to do the hardway).

      In conversation Sunday, 29-Jan-2023 05:05:14 UTC permalink
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 05:05:14 UTC Srevin Saju Srevin Saju
      in reply to

      I had been looking at what `MOV AH, 0x0E` means and I found this https://forum.osdev.org/viewtopic.php?f=13&t=31031, a 13 year old had been trying to make a bootloader. wow I feel so old.

      In conversation Sunday, 29-Jan-2023 05:05:14 UTC permalink

      Attachments

      1. OSDev.org • View topic - What does 'mov ah, 0x0e' mean and do?
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 18:16:51 UTC Srevin Saju Srevin Saju
      in reply to
      • Bernie

      @codewiz I am using the nasm assembler, it was the one specified in our university study material.

      In conversation Sunday, 29-Jan-2023 18:16:51 UTC permalink
    • Srevin Saju (srevinsaju@mstdn.io)'s status on Sunday, 29-Jan-2023 18:18:05 UTC Srevin Saju Srevin Saju
      in reply to
      • Bernie

      @codewiz Ah names are really confusing, most of my professors and books refers to them as “procedures” :/

      In conversation Sunday, 29-Jan-2023 18:18:05 UTC permalink
    • Bernie (codewiz@mstdn.io)'s status on Sunday, 29-Jan-2023 20:08:50 UTC Bernie Bernie
      in reply to

      @srevinsaju Looks like it's still actively developed:
      https://github.com/netwide-assembler/nasm

      I never used nasm because it came from the DOS/Windows world and uses the Intel syntax (as opposed to the AT&T syntax, which is standard in UNIX/Linux toolchains).

      #assembly #programming #retrocomputing

      In conversation Sunday, 29-Jan-2023 20:08:50 UTC permalink

      Attachments


    • Bernie (codewiz@mstdn.io)'s status on Sunday, 29-Jan-2023 20:20:22 UTC Bernie Bernie
      in reply to

      @srevinsaju Here's some Motorola 68000 #asm I wrote long ago for the #Amiga:
      https://www.codewiz.org/projects/amiga/XModule/XModuleSrc/Startup.asm

      How does it look compared to 8086 asm?

      In conversation Sunday, 29-Jan-2023 20:20:22 UTC permalink

      Attachments


    • Bernie (codewiz@mstdn.io)'s status on Sunday, 29-Jan-2023 20:25:47 UTC Bernie Bernie
      in reply to

      This is part my first open source project, a GUI tracker and module format converter.

      I never managed to finish it, and now it seems silly to spend time rewriting the entire C startup code in assembly, when it's not at all performance critical.

      But that's how kids learn!

      @srevinsaju #programming #asm

      In conversation Sunday, 29-Jan-2023 20:25:47 UTC permalink
    • Bernie (codewiz@mstdn.io)'s status on Sunday, 29-Jan-2023 20:42:44 UTC Bernie Bernie
      in reply to

      @srevinsaju Ok, there's no official naming convention, but this is how early programming languages progressed:

      ROUTINE: a block of instructions that accomplishes a task. You can JMP to it and it doesn't necessarily return (e.g.: "the init routine jumps to the loader routine, which jumps to the main screen routine...")

      In conversation Sunday, 29-Jan-2023 20:42:44 UTC permalink
    • Bernie (codewiz@mstdn.io)'s status on Sunday, 29-Jan-2023 20:45:39 UTC Bernie Bernie
      in reply to

      SUBROUTINE: a routine designed to be called from multiple locations and return to the caller.

      Late 1970s CPU designs supported this programming model by adding a stack pointer register (SP) and dedicated opcode pairs like JSR/RTS (m68k) and CALL/RET (x86).

      @srevinsaju #programming #asm

      In conversation Sunday, 29-Jan-2023 20:45:39 UTC permalink
    • Bernie (codewiz@mstdn.io)'s status on Sunday, 29-Jan-2023 21:08:21 UTC Bernie Bernie
      in reply to

      PROCEDURE: ALGOL 60, the precursor of all modern procedural languages, including C, introduced the concept of passing arguments to subroutines. Argument passing used the awkward "call-by-name", but the VALUE keyword let you override it. There were no pointers and no references yet.

      Modern calling conventions pass the first N arguments in registers, and push the rest on the stack. This is what you'd use in your 8086 asm.

      @srevinsaju #programming #asm #retrocomputing

      In conversation Sunday, 29-Jan-2023 21:08:21 UTC permalink
    • Bernie (codewiz@mstdn.io)'s status on Sunday, 29-Jan-2023 21:34:35 UTC Bernie Bernie
      in reply to

      FUNCTION: Lisp was ahead of its time, with first-class functions in the '60s.

      My first encounter with functions was in BASIC. The Commodore dialect had built-in functions such as SIN(X), and supported a limited form of user-defined functions with a single argument and a one-line expression:

      DEF FN TRIPLE(X) = X*3

      Calls could nest:

      PRINT FN TRIPLE(FN TRIPLE(5) + 1)

      @srevinsaju #programming #retrocomputing

      In conversation Sunday, 29-Jan-2023 21:34:35 UTC permalink
    • Bernie (codewiz@mstdn.io)'s status on Sunday, 29-Jan-2023 21:43:23 UTC Bernie Bernie
      in reply to

      Pascal had an explicit distinction: functions are procedures which return a result.

      K&R C didn't bother with procedures: everything is a function, and if you omit return at the end, it will return garbage to the caller 😂

      Later, ANSI C added the "void" type and (optional) function prototypes, making this footgun somewhat less dangerous.

      Support for declaring and defining functions without a full prototype will be finally removed in C23:
      https://en.cppreference.com/w/c/23

      @srevinsaju #programming

      In conversation Sunday, 29-Jan-2023 21:43:23 UTC permalink

      Attachments


    • Bernie (codewiz@mstdn.io)'s status on Sunday, 29-Jan-2023 22:35:01 UTC Bernie Bernie
      in reply to
      • Amand Tihon

      @alrj You beat me on time, but see the rest of my monologue 🙂

      I was forced to use Turbo Pascal in high school. I complained that it was an obsolete language, but my teacher insisted that it was good for me so I wouldn't learn bad habits from C... like early return, break, continue...

      In formal circles, those constructs were accused of being "non-structured" control flow, so my teacher would argue that adding flags to abort loops was better style 🤦♂️

      @srevinsaju #programming

      In conversation Sunday, 29-Jan-2023 22:35:01 UTC permalink
    • Amand Tihon (alrj@hostux.social)'s status on Sunday, 29-Jan-2023 22:35:12 UTC Amand Tihon Amand Tihon
      in reply to
      • Bernie

      @srevinsaju @codewiz A few languages, most notably #Pascal, used to make a distinction between functions, that return a value, and procedures, that do not.

      In conversation Sunday, 29-Jan-2023 22:35:12 UTC permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • Privacy
  • Source
  • Version
  • Contact

Bobinas P4G is a social network. It runs on GNU social, version 2.0.1-beta0, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All Bobinas P4G content and data are available under the Creative Commons Attribution 3.0 license.