Machine Code Instructions

Поділитися
Вставка
  • Опубліковано 28 гру 2024

КОМЕНТАРІ • 214

  • @semtex6412
    @semtex6412 4 роки тому +44

    7 years later and this video is relevant now more than EVER! top man Mr. Jones! can't thank you enough Sir!

  • @jorgecarrascal5284
    @jorgecarrascal5284 Рік тому +4

    I want to thank you for your video!!! I studied this long time ago, but it is wonderful you decided to post this video so more people can understand how a computer works!!!
    Information and understanding it, is important in human development!!!!
    THANK YOU

    • @johnphilipjones
      @johnphilipjones  Рік тому +1

      Thank you for your comment it is appreciated.
      Best wishes
      Phil

  • @Mikeymikers1
    @Mikeymikers1 2 роки тому +2

    this helps me in understanding ethereum and how EVM bytecodes work. thanks a bunch!

  • @tedwoodpeacock4689
    @tedwoodpeacock4689 6 років тому +16

    Truly the most brilliant video series I have ever seen when it comes to explaining this topic. I can't believe how much I appreciate them. Thank you so much!

  • @tubeMonger
    @tubeMonger 3 дні тому +1

    Thanks. My goal is to learn assembly in 2025. This and your othe rexplanations made my task a lot clearer.

    • @johnphilipjones
      @johnphilipjones  День тому

      It is good to know that the videos help.
      Best wishes Phil

  • @alzalame
    @alzalame 6 років тому +9

    Probably the best explanation that i have ever seen , short , constructive , hit's brain directly , thank you very much !

  • @cherifaly6757
    @cherifaly6757 6 років тому +8

    This is by far the best way of teaching computer science! Thanks alot!

  • @petraflorkova2728
    @petraflorkova2728 5 років тому +2

    May I say... how GRATEFUL I am for your amazing videos
    Thank you

  • @prod.bythisjustin8449
    @prod.bythisjustin8449 4 роки тому +5

    you are literally amazing and finally, allowing me understand this topic for my ee class.

  • @johnphilipjones
    @johnphilipjones  11 років тому +4

    Thank you for your comment. I am concentrating on Python videos at the moment but will return to more on machine code late next year.
    Best wishes
    Phil

  • @sayedkazimi6008
    @sayedkazimi6008 4 роки тому +3

    Very useful! I missed watching your videos. I like your explanation 👍🏼👍🏼

  • @TimCrinion
    @TimCrinion 9 років тому +33

    I really want to watch a video of how they got from fiddling with transistors by hand to something that can interpret instructions.

    • @johnphilipjones
      @johnphilipjones  9 років тому +8

      +Tim Crinion That would be a long duration video
      Best
      Phil

    • @Dominoes282
      @Dominoes282 9 років тому +7

      +Tim Crinion I just went through a 4 month 200 level class to learn that. It's not easy m8.

  • @2GFactFinder
    @2GFactFinder 7 років тому +7

    Yes it is like having a personal tutor. Excellent and thank you very much.

  • @AndreUltrasi
    @AndreUltrasi 8 років тому +3

    Thank you so much, here in Brazil there aren't video explanations like this.

  • @johntolkien9629
    @johntolkien9629 7 років тому +11

    Great stuff Scouse ! Super clear presentation. Hope other "teachers" gain your skill in clear communication. Keep up the good work !

  • @hongkongcantonese501
    @hongkongcantonese501 3 роки тому +3

    Extremely clear.

  • @maklasik
    @maklasik 7 років тому +4

    Was looking for this kind of explanation for 5 hours! Thank you very much.

  • @jay2short2
    @jay2short2 8 років тому +6

    You replies are actually better than the video itself. Great information, Phil, nice one !

  • @nontraditionaltech2073
    @nontraditionaltech2073 4 роки тому +4

    AWESOME video, just subbed! I’m a CS guy that loves the CE domain more than anything. This video has really helped me, getting ready to start writing a 6502 emulator. I will for sure check out your other videos as well. Cheers!

    • @johnphilipjones
      @johnphilipjones  4 роки тому

      Thank you for the positive feedback it is appreciated.
      Best wishes Phil

  • @a.a7907
    @a.a7907 8 років тому +2

    Thanks for sharing these useful tutorials. They helped me a lot understanding how does CPU work, and how can I understand Assembly.

  • @mashanishadi5911
    @mashanishadi5911 10 років тому +2

    Thank you so much! Your videos are very useful and easy to follow. please upload more!

    • @johnphilipjones
      @johnphilipjones  10 років тому +2

      Thank you for your comments I hope to upload two or three a week.
      Bw
      Phil

  • @FFoscarr
    @FFoscarr 4 роки тому +3

    John phillip jones, this video is astounshing and really helped me. Really impeccable.

  • @Daelion164
    @Daelion164 11 років тому +9

    Thanks for this. You made something that I thought was complicated really, really simple.

  • @gamingweek-mv4mr
    @gamingweek-mv4mr 8 місяців тому +1

    Man you realy helped no would could help me like this keep up the good work

  • @jibreelkeddo7030
    @jibreelkeddo7030 7 років тому +1

    I am not a CS major but rather an MIS major, it's cousin. I chose MIS to make getting an MBA easier in the future, but man, do I love coding from the bottom of my heart. It's awesome, and high level coding comes to me pretty naturally.
    Even if I will never use it, I want to learn low level coding too. It's fascinating. Now if only I could understand it just a bit better >.>

  • @christiancarter255
    @christiancarter255 5 років тому +5

    Beautiful!
    I want to one day program in binary. Literally. Even just a little.
    Thank you for showing binary representations of some the assembly instructions.

  • @isaiasprestes
    @isaiasprestes 6 років тому +3

    Gosh! Finally a very good explanation about this topic. Thanks John!! You made my day!

  • @protossscud8435
    @protossscud8435 11 років тому +2

    informative, good and clear tutorial , please make more , thanks !

  • @Sancarn
    @Sancarn 3 роки тому

    The lookup tables for getting from Assembly instructions to Opcodes - are these available / queryable from the OS?

    • @johnphilipjones
      @johnphilipjones  3 роки тому

      You would need to install an assembler. To get the opcodes search on google for the instruction set of the processor.
      Best wishes
      Phil

  • @nailnadiroglu8830
    @nailnadiroglu8830 4 роки тому +1

    Great Teaching.

  • @malteeaser101
    @malteeaser101 11 років тому +4

    I get how you know that 01H is 00000001 in binary... But how do you convert the LD A into binary? Or is it something your remember from a list? I have to convert it into machine code, is machine code binary?

    • @johnphilipjones
      @johnphilipjones  11 років тому +3

      This is a very good question. Machine code is the language of the machine (I.e low and high voltage levels) which as humans we represent as binary. Every machine code instruction has it's own binary number. Load A with immediate data has the binary number 00111110 which is 3E in hexadecimal (an easy way to remember binary). So every instruction has it's own binary number. Every instruction has it's own binary number so in a sense it comes from a list as you suggest. However, in truth each number makes the electronics behave in a specific way. The binary patterns open and close electronic solid state switches that perform a simple task that when all executed in a specific order are able to implement sophisticated functionality.

    • @malteeaser101
      @malteeaser101 11 років тому +3

      John Philip Jones So does LOAD have it's own binary number? Or for example do LOAD A, LOAD B and LOAD C count as three different things with three separate binary numbers representing them?
      And does this mean that there is no way of mathematically converting LOAD A into binary in your head/on paper without a table that literally tells you which binary number represents each op code I think it's called?

    • @johnphilipjones
      @johnphilipjones  11 років тому +3

      malteeaser101 LD A, N has its own binary number called an Operation code. LD B, N has a different operation code. When writing assembly language program you type in instructions such as LD A, N and an assembler (computer program) converts the assembly language to machine code (i.e. binary patterns). You can also do the conversion as a human it is called hand assembly and it means you would have to either know all the codes or access them from a printed list.Back in the day I used to code in assembly and as sad as it may sound I knew all of the codes. But there was only around 70 different instructions for the machines I was working on.

    • @malteeaser101
      @malteeaser101 11 років тому

      John Philip Jones Haha thanks, I have a assessment due in soon and this helped A LOT.

    • @johnphilipjones
      @johnphilipjones  10 років тому +2

      Mo Fo Hello Mo, Every 'type' of CPU (processor) has its own machine code language and related assembly language. For example Intel processors are different to Motorola processors and have a different machine code language from one another. The description I have put forward is based on the Zilog Z80 processor which also has its own machine code language.
      I am unsure what machine code language you are referring to but what you are describing is what is often called absolute addressing The term addressing refers to how data is accessed by an individual machine code instruction. I have a short series of videos that show the difference. I have put links to their playlist below:
      ua-cam.com/play/PL6lxxT7IdTxGXX6D6j-zjzcgoOD8WYMS2.html
      Phil

  • @stephenbaka
    @stephenbaka 7 років тому +2

    Nice work, thank you for your clear explanation.

  • @ankitkurup3891
    @ankitkurup3891 8 років тому +4

    sir ,is it true that increment operation is done in instruction decode phase only??

  • @fintarabg
    @fintarabg 10 років тому +1

    Thanks! You should do more videos on this topic as you explain this matter very, very well!

    • @johnphilipjones
      @johnphilipjones  10 років тому +1

      I will be doing more once I have finished doing the Python programming video
      Best wishes
      Phil

  • @hamzaism2712
    @hamzaism2712 11 років тому +1

    awesome tuto ,and it will be great if you can make a series about programming
    in assembly (emulator 8086 or something like that )
    and thanks

  • @sfxmzxc
    @sfxmzxc Рік тому +2

    i'm lerning in chanel ser ...Thanks

  • @hoangduy500
    @hoangduy500 2 роки тому +1

    you just saved me. Thanks a lot :D!

    • @johnphilipjones
      @johnphilipjones  2 роки тому +1

      Good to hear that the video helped.
      Best wishes Phil

  • @hamzaism2712
    @hamzaism2712 11 років тому +1

    awesome explanation thanx,and it will be great if you can make a video series about
    programming using emulator 8086 or something like that

  • @freecrac
    @freecrac 7 років тому +2

    For Intel 80386+ CPU:
    Instruction Prefix 0 or 1 Byte
    Address-Size Prefix 0 or 1 Byte
    Operand-Size Prefix 0 or 1 Byte
    Segment Prefix 0 or 1 Byte
    Opcode 1 or 2 Byte
    Mod R/M 0 or 1 Byte
    SIB, Scale Index Base (386+) 0 or 1 Byte
    Displacement 0, 1, 2 or 4 Byte (4 only 386+)
    Immediate 0, 1, 2 or 4 Byte (4 only 386+)
    Format of Postbyte(Mod R/M from Intel-Doku)
    ------------------------------------------
    MM RRR MMM
    MM - Memory addressing mode
    RRR - Register operand address
    MMM - Memory operand address
    RRR Register Names
    Filds 8bit 16bit 32bit
    000 AL AX EAX
    001 CL CX ECX
    010 DL DX EDX
    011 Bl BX EBX
    100 AH SP ESP
    101 CH BP EBP
    110 DH SI ESI
    111 BH DI EDI
    ---
    16bit memory (No 32 bit memory address prefix)
    MMM Default MM Field
    Field Sreg 00 01 10 11=MMM is reg
    000 DS [BX+SI] [BX+SI+o8] [BX+SI+o16]
    001 DS [BX+DI] [BX+DI+o8] [BX+DI+o16]
    010 SS [BP+SI] [BP+SI+o8] [BP+SI+o16]
    011 SS [BP+DI] [BP+DI+o8] [BP+DI+o16]
    100 DS [SI] [SI+o8] [SI+o16]
    101 DS [DI] [DI+o8] [SI+o16]
    110 SS [o16] [BP+o8] [BP+o16]
    111 DS [BX] [BX+o8] [BX+o16]
    Note: MMM=110,MM=0 Default Sreg is DS !!!!
    32bit memory (Has 67h 32 bit memory address prefix)
    MMM Default MM Field
    Field Sreg 00 01 10 11=MMM is reg
    000 DS [EAX] [EAX+o8] [EAX+o32]
    001 DS [ECX] [ECX+o8] [ECX+o32]
    010 DS [EDX] [EDX+o8] [EDX+o32]
    011 DS [EBX] [EBX+o8] [EBX+o32]
    100 SIB [SIB] [SIB+o8] [SIB+o32]
    101 SS [o32] [EBP+o8] [EBP+o32]
    110 DS [ESI] [ESI+o8] [ESI+o32]
    111 DS [EDI] [EDI+o8] [EDI+o32]
    Note: MMM=110,MM=0 Default Sreg is DS !!!!
    ---
    SIB is (Scale/Base/Index)
    SS BBB III
    Note: SIB address calculated as:
    =+*(2^(Scale))
    Fild Default Base
    BBB Sreg Register Note
    000 DS EAX
    001 DS ECX
    010 DS EDX
    011 DS EBX
    100 SS ESP
    101 DS o32 if MM=00 (Postbyte)
    SS EBP if MM00 (Postbyte)
    110 SS ESI
    111 DS EDI
    Fild Index
    III register Note
    000 EAX
    001 ECX
    010 EDX
    011 EBX
    100 never Index SS can be 00
    101 EBP
    110 ESI
    111 EDI
    Fild Scale coefficient
    SS =2^(SS)
    00 1
    01 2
    10 4
    11 8

  • @angelfishgod
    @angelfishgod 7 років тому +2

    Very informative! Thank you for the quality upload.

  • @abdumo4336
    @abdumo4336 3 роки тому +1

    Thank you Mr John!!!!

  • @gregclare
    @gregclare 4 місяці тому

    Nicely done. But @5:54 the name “Immediate” actually refers to the operand being the actual data to operate on. As opposed to the operand being an address, or an offset, that points to the data (or further indirection). Specifically, “Immediate” does not mean the operand immediately follows the opcode, as you have stated. Clearly, the operand always immediately follows the opcode. The operand just isn’t always the “immediate” actual data to operate on.

    • @johnphilipjones
      @johnphilipjones  4 місяці тому +1

      What you are referring to is addressing modes. If the data to be processed by the instruction follows the opcode, then the addressing mode is referred to as immediate addressing. Another instruction can have the address of the data just after the opcode. This address gives the memory address of where the data to be processed can be located. This type of instruction is said to have an absolute addressing mode.
      Immediate addressing is covered by the video at the link below:
      ua-cam.com/video/C6P2s5J9RaM/v-deo.htmlsi=LuW6LxR811gcGlZ_
      Absolute addressing is covered by the video at the link below:
      ua-cam.com/video/L8RVT0zG8Zk/v-deo.htmlsi=EsyWTnOtZBb8ThUi
      As an aside the addressing mode shown in the video at the link below is an example of implied addressing.
      ua-cam.com/video/XM4lGflQFvA/v-deo.htmlsi=CwcaGDV0h8ju9Kso
      Best wishes
      Phil

    • @gregclare
      @gregclare 4 місяці тому

      @@johnphilipjones Hi Phil. I do understand all of that. I’m old school. I started off hand-assembling machine code on my own self-built 8-bit microprocessor designs in the late 70’s. So I do have a pretty solid understanding of all of this. I was just trying to give some helpful feedback for your students.
      What I was pointing out is that @5:54 you specifically say: “the name immediate addressing comes from the fact that the operand comes immediately after the opcode”. This statement is potentially confusing to learners. i.e. The fact that the operand comes immediately after the opcode is a general statement, not specific to the addressing mode.
      I believe what you meant to say is more along the lines of: “the name immediate addressing comes from the fact that the operand is the actual data to be processed by the opcode”. This would then be consistent with what you have now clarified in your reply above.
      Hopefully you take this as the helpful constructive feedback I'd intended. 🤓

    • @johnphilipjones
      @johnphilipjones  4 місяці тому

      Hello Greg,
      Yes you are correct I missed your point initially. I am always happy for feedback and comments. It was, and is, taken as constructive.
      Best wishes
      Phil

  • @ameeaty4088
    @ameeaty4088 2 роки тому +1

    this was awesome thank you

  • @banwarifageriaexcelclasses1447
    @banwarifageriaexcelclasses1447 7 років тому +1

    very educative lesson ..sir can you please , prepare simple and nice video on VBA for beginners

  • @danekerkkamp2746
    @danekerkkamp2746 2 роки тому

    So if I had for example machine code: 0xE1160547, the resulting assembly instruction would be the binary equivalent?

  • @2359-UK
    @2359-UK 8 років тому

    This video is fantastic. thanks for the lecture. thanks for posting it.

    • @johnphilipjones
      @johnphilipjones  8 років тому

      +Lo Janus Thank you for your generous comment.
      Regards
      Phil
      (John Philip Jones)

  • @AbhishekKumar-oy2hw
    @AbhishekKumar-oy2hw 6 років тому +4

    Thank you very much for this very clear and precise explanation..

  • @ehsanullahkhan5117
    @ehsanullahkhan5117 7 років тому +1

    Very helpful. ... carry on plz

  • @zinturis
    @zinturis 9 років тому +2

    Great stuff! Thanks. Is it necessary to convert instructions and operands to hex numbers? Can you keep instructions as binary code instead of 3E or something like that?

    • @johnphilipjones
      @johnphilipjones  9 років тому +1

      +zinturis You would normally code in assembly language and this is converted to the necessary binary codes by the assembler. So in the machine you would actually see binary and not hexadecimal. However, it is usual to look at the binary in hexadecimal as it is easier for us to remember hexadecimal numbers rather than long binary numbers and it is also easy to convert between binary and hexadecimal. The following videos look at converting between Hexadecimal and binary:
      ua-cam.com/video/fhgk2rxrn-Q/v-deo.html
      ua-cam.com/video/V-he1Ip36OA/v-deo.html
      Best wishes
      Phil
      (John Philip Jones)

    • @zinturis
      @zinturis 9 років тому

      Thanks a lot for the quick answer. Sorry if my questions may sound stupid, I am quite newbie in this but if you want to send certain instructions of machine code to the processor, what's the workflow of that? Can you do it from some terminal or do you need to create a text file and save as .bin or .. how that works in practice? I mean, how to control that process?

    • @johnphilipjones
      @johnphilipjones  9 років тому +1

      +zinturis You use an editor and type in your assembly language program and save it in a text file and use an assembler to convert your typed in program to machine code. You will need to download an assembler to match the CPU of your computer. However, a good way to learn is to download a CPU emulator that has an assembler incorporated. I used to do assembly programming on a Z80 flight micro-board, a 6511 micro-controller using an in-circuit emulator. However, these have now been superseded and I am not sure what is used today. However, I believe that the Raspberry Pi has a set up that allows for machine coding. I would recommend searching with the phrase "machine code emulator" and see what is out there to assist. Hope this helps.
      Best wishes
      Phil
      (John Philip Jones)

    • @zinturis
      @zinturis 9 років тому

      From your earlier respond, I understand that assembly language is different for different CPUs? So, if I write z=x+y for Intel it is not gonna work on an AMD based computer? So what's different? Assembly commands or register addresses?

    • @johnphilipjones
      @johnphilipjones  9 років тому +1

      zinturis z = x + y is a high level statement and will be converted to the machine code of the CPU that is 'in' your computer by a compiler. However, putting this aside the opcode for add on each different type of CPU is different. Each processor also has a different register set i.e. different number of registers and of different lengths. The architecture of the CPU's can also be different some are RISC other CISC or a combination of both CISC and RISC.

  • @billallwell6507
    @billallwell6507 7 років тому

    Very nice. So we can either write out the assembler on a piece of paper, then convert on the paper and then maybe (in the early days) use switches to set each memory address with the correct sequence of binary bits ? The part I still get stuck on is that the assembler can also be a program to convert the codes for us. Is this a program that would be loaded into memory, and therefore the first assemlber would have had to have been hand written (from what I've read, but still a little confused )and manually placed in the memory ?

    • @johnphilipjones
      @johnphilipjones  7 років тому

      When you switch on a computer the electronics generates an electrical pulse. This pulse is applied to a CPU pin that causes a machine code instruction to be fetched from a specific memory location. This instruction is the first instruction of the boot program other instruction are then fetched decoded and executed in order one after another. This boot program then sets up the operating system by loading other programs that form the operating system. Once the operating system is in place it is able to load up other programs (such as the assembler) at the request of the user (i.e by clicking on an icon or by issuing a command).
      In the very early days switches were indeed throw to enter the program you wished to execute.

  • @khalidnawaz6536
    @khalidnawaz6536 3 роки тому +1

    VERY GOOD SIR.PLEASE UPLOAD FEW MORE VIDEOS

    • @johnphilipjones
      @johnphilipjones  3 роки тому

      Check out www.PythonByteSize.com
      Best wishes Phil

  • @MelissaMelissasthlm
    @MelissaMelissasthlm 2 роки тому

    Hello, great video. My question is , are the registers hexadecimal form?

    • @johnphilipjones
      @johnphilipjones  2 роки тому

      The registers actually hold binary patterns. It is usual to show these patterns in their hexadecimal form because as humans it is difficult for us to remember long binary patterns. It is much easier to remember hexadecimal and it is relatively easy to convert between binary and hexadecimal.
      Best wishes Phil

  • @skynet320
    @skynet320 9 років тому +1

    Thank you sir for the video. But my question still is, how do you convert the assembly language code to machine code (opcode).Your reply will be much appreciated.

    • @johnphilipjones
      @johnphilipjones  9 років тому +1

      +Hammad Ahmed You write your program in assembly language and an assembler converts the assembly language to machine code.
      Regards
      Phil
      (John Philip Jones)

  • @vinayaksomalwar1232
    @vinayaksomalwar1232 11 років тому

    Great video! Very visual! Keep it up!

  • @alexpark-q8m
    @alexpark-q8m 5 років тому +1

    How are you doing sir, I liked this youtube very much sir, I am expected you are making these kind of, more sir

  • @danishbhatia5004
    @danishbhatia5004 9 років тому

    hey thanx for this tutorial but how did you find the opcode for the instructions like inc, add, mov and so on....

    • @johnphilipjones
      @johnphilipjones  9 років тому +1

      Danish Bhatia All microprocessors have an instruction set. This is a list of instructions in together with there hexadecimal equivalent. The link below will take you to an instruction set in PDF format which can be downloaded.

    • @johnphilipjones
      @johnphilipjones  9 років тому

      Danish Bhatia oops this is the link:
      www.zilog.com/appnotes_download.php?FromPage=DirectLink&dn=UM0080&ft=User%20Manual&f=YUhSMGNEb3ZMM2QzZHk1NmFXeHZaeTVqYjIwdlpHOWpjeTk2T0RBdmRXMHdNRGd3TG5Ca1pnPT0=

  • @simonlee2817
    @simonlee2817 9 років тому

    I want to know about how machine code is executed. I mean, since you already have these 1s and 0s in RAM, how can the CPU tell from so many instructions and do different actions correspondingly?

    • @johnphilipjones
      @johnphilipjones  9 років тому +1

      +Simon Lee When you switch on a microprocessor system (e.g. a computer) the hardware will always look in the same memory location. This location must hold the first operation code to be executed i.e. the program to be executed starts at this memory location. For a computer this is the boot program. For an embedded system containing a microprocessor this location would contain the first operation code for the first program to be executed.

    • @simonlee2817
      @simonlee2817 9 років тому

      +John Philip Jones I am sorry, but I am still confused. I mean how the CPU can know these 1s or 0s mean MOV, ADD or SUB etc. How do 1s and 0s make sense to the CPU and indicate the CPU what to do?

    • @johnphilipjones
      @johnphilipjones  9 років тому +1

      +Simon Lee A microprocessor system is a collection of million of switches that control the movement of binary patterns along bus systems, In addition these switches can be arranged to perform logic and arithmetic operations. The control of these switches is achieved by another lower level language that is not machine code. However, the machine code is able to dictate which parts of this lower level language execute. Certain patterns within the machine code select the Mov, Inc parts of the lower level language that is to execute.

    • @simonlee2817
      @simonlee2817 9 років тому

      +John Philip Jones So, there is a lower level language than machine code. What it is? It seems to be getting complicated, is there any website or book that gives a detailed information and help me understand?

    • @johnphilipjones
      @johnphilipjones  9 років тому +4

      +Simon Lee One of the levels below is microcode and this is responsible for directing binary patterns throughout the CPU. The main controlling subsystem within the CPU is the control unit. However, my advice is not to go below machine code as unless you are an electronic engineer it is more likely to confuse any understanding of how you can control a microprocessor system using machine code. My recommendation is to consider the register set of a typical CPU and use register transfer language (RTL) to understand how each machine code instruction executes. The best way is to look at manuals associated with a microprocessor (although they are not easy reads). A good starting place is to search for the "Z80 assembly language manual".
      Hope this helps
      Phil

  • @jibreelkeddo7030
    @jibreelkeddo7030 7 років тому +1

    This video helps a lot. Thank you :)

  • @orbita1
    @orbita1 9 років тому

    Hi, I hope you can help me:
    I know what opcodes are and how they work, but i want to know something that i have just realised i've overlooked all this time, assembled code (binary after assembly) is just a sequence of instructions in the .text section right? (so all the opcodes with applicable operands).
    If so, i was wondering essentially how the CPU knows what each opcode actually refers to e.g. how does 0xDE mean 'load'?
    for example: say the cpu of a microcontroller turns on, the program counter = 0, so it loads the first opcode in .text (at the start of the section) into cpu and a hardware decoder in the cpu physically decodes each opcode which allows the CPU to translate the intended instruction into the correct operation, right? (then as program counter increments, you process the next operation (opcode)in .text).
    cheers!

    • @simonlee2817
      @simonlee2817 9 років тому

      +orbita1 I think I just have the same confusion like you. How can these 1s and 0s make sense to the CPU and be executed differently?

    • @thandermax
      @thandermax 9 років тому +1

      +orbita1 Each OS has it's own standard of executable (Windows - PE, Linux - ELF...). OS loads the executable and parses the exe header and finds out starting address. OS loader then memory maps the exe and sets IP or EIP register to proper starting address by context switching. The program then continues there on. Now depending on addressing mode, the operand can be from .text part or .bss or .data? etc segment.
      But the first instruction (after switching on) is always a predefined address. For Intel/AMD IBM compatible pc, it is FFFFFFF0h or FFFF0h (depending on 32bit/16bit). Most of them are pointing to BIOS startup routines, which sets up rest of the booting process. Once the ball starts rolling, it works.

    • @marchawley6830
      @marchawley6830 7 років тому +1

      Your struggle may be related to asking how does the computer "understand." Perhaps it would help to remember that a computer is merely a bunch of switches. Some of those switches turn other switches on and off. The computer does not "understand" anything in the way a human understands things. The computer is just switches which have been arranged by humans in such a way that certain switches turn other switches on and off in a way to represent numbers and characters understandable to humans. A light switch does not "understand" that the up position means that it is been asked to light the room. When the switch is in the up position power flows to the light because humans have designed the circuit to work that way.

  • @billyfromzera4162
    @billyfromzera4162 2 роки тому +2

    It old but it still so good

  • @sanaaf5209
    @sanaaf5209 10 років тому

    How we should find opcode for an operation is there any method r it is assigned value

    • @johnphilipjones
      @johnphilipjones  9 років тому +1

      +sanaaf Each microprocessor will have it own user manual and there will be a list of assembly language instruction and in the column next to the instruction will be the hexadecimal value for the instruction. However, you would normally type up the program using an editor and use an assembler to convert the program to machine code (i.e. hexadecimal which is a way to represent binary).
      Regards
      Phil
      (John Philip Jones)

  • @ShahidQureshi-ee6wz
    @ShahidQureshi-ee6wz 5 років тому

    Can assembly language play a significant role in programming for the Super Computers?

    • @johnphilipjones
      @johnphilipjones  5 років тому +1

      I have never coded for a super computer so cannot really comment. However, I used to code a lot in machine code. What I can say is that all languages are translated to machine code which then 'controls' the microcode (and/or the 'hardwiring'). With a FULL knowledge of the CPU you can always ensure a very efficient execution time when using machine code (well assembly language to be more accurate). However, it would take you an extremely long time to code any meaningful system using machine code. The C programming language has many efficient libraries for controlling CPUs and C programs can be much quicker to 'code up' than assembly language.

  • @micahgilbertcubing5911
    @micahgilbertcubing5911 6 років тому +2

    Awesome! This helps so much with a personal project of mine (using logisim to simulate an 8 bit CPU)

  • @s.dcreations3978
    @s.dcreations3978 5 років тому

    Sir,how opcode and operands are combined in an instruction and how they are seperated in an instruction.

    • @johnphilipjones
      @johnphilipjones  5 років тому

      The first binary pattern (or first bits in the pattern) fetched fromm memory when you execute a program is always the opcode. Once decoded the instruction knows what to do with the rest of the instruction. This usually involve going back to the memory to get the operand. Once the current instruction has executed the CPU goes back to the memory to fetch the next instruction the and this will be the opcode.

    • @s.dcreations3978
      @s.dcreations3978 5 років тому

      @@johnphilipjones thank u sir and which digital circuits are invovlved in joining both opcode and operand together in an instruction.

  • @moon6080
    @moon6080 8 років тому

    would you be able to do a video on floating point binary?

  • @SubbirHosain
    @SubbirHosain 5 років тому

    how to get opcode for different instruction set?

    • @johnphilipjones
      @johnphilipjones  5 років тому

      The following link takes you to the instruction set for the Z80: z80-heaven.wikidot.com/instructions-set
      Best wishes
      Phil

  • @tqwewe
    @tqwewe 7 років тому

    You used the term "INC A" quite often... but when you showed the binary or hex representation of it, it doesn't seem to include the 'A' part... I'm guessing because it's A (the first register of the CPU), you just omit it, but when you want to access B or C, would you simply have an operand directly proceeding the 3D (INC) Op Code?
    (Tried to make it as simple as possible to understand, sorry)

    • @johnphilipjones
      @johnphilipjones  7 років тому

      INC B would have a different opcode. INC C would also have a different opcode

  • @overclucker
    @overclucker 6 років тому

    I've been learning assembly for a while, but I had no clue that the destination register is part of the operator. I've been thinking of a and b as both being operands, but I guess it's not the case. Looks like people who use AT syntax are subtracting backwards =/

    • @johnphilipjones
      @johnphilipjones  6 років тому

      With machine code I would recommend that you consider source and destination for the 'data items' (i.e. operands)

  • @dylanisaac1017
    @dylanisaac1017 4 роки тому

    where do you get this information from

    • @johnphilipjones
      @johnphilipjones  4 роки тому +1

      The chip manufacturers have manuals on instruction sets. I used the Z80 manual for the information in this video. Back in the day I used to program this chip using assembly language and machine code. Do a Google search on the following to get the manual.
      Zilog Z80 manual
      Best wishes Phil

  • @stephenobrien2952
    @stephenobrien2952 4 роки тому

    what software do you use to produce the videos?

    • @johnphilipjones
      @johnphilipjones  4 роки тому

      I have put this info at the following link:
      www.pythonbytesize.com/educators.html
      Best wishes
      Phil

  • @sergeantcrow
    @sergeantcrow 9 років тому +2

    Thank you for these tutorials...
    I am far more happier immersing myself in this type of learning activity than getting caught up watching political videos on UA-cam.. For old times sake I have just discovered and installed Turbo C on my PCs like I used in the 90s...

  • @michaelwilson5454
    @michaelwilson5454 9 років тому

    Very good video. You did a good job explaining this and the images shown really helps a lot. Thanks...

    • @johnphilipjones
      @johnphilipjones  9 років тому

      Thank you
      Best wishes
      Phil Jones
      (John Philip Jones)

  • @kcvinu
    @kcvinu 2 роки тому +1

    Helpful video.

  • @johntolkien9629
    @johntolkien9629 7 років тому

    Hi John - Are you using Z80 opcodes here ?

  • @anisassassino5000
    @anisassassino5000 6 років тому +3

    thank you it was very helpful :D !

  • @junioralamu7438
    @junioralamu7438 Рік тому

    The op codes we learning are only 4 bits and the remaining 12 bits are the address, can you explain this? please

  • @harithreddy2603
    @harithreddy2603 10 років тому

    thanq sir..good work.... like to see ur more videos on youtube

    • @johnphilipjones
      @johnphilipjones  10 років тому

      Check out the following websites where I list all of the videos
      www.johnphilipjones.com/index.html
      www.pythonbytesize.com/
      Best wishes
      Phil

  • @NANO-SERWIS.MAREK-DASZKE
    @NANO-SERWIS.MAREK-DASZKE 4 роки тому +1

    Very Nice :)

  • @estebanmorales4089
    @estebanmorales4089 5 років тому +1

    Good video

  • @yerriswamyk.m6530
    @yerriswamyk.m6530 8 років тому

    Can you tell me how assembler converts Mnemonics into opcode.

    • @johnphilipjones
      @johnphilipjones  8 років тому +2

      There is essentially a table that contains the mnemonics and opcode in there own column. The mnemonics (i.e. assembly language program) is supplied as a file to a computer program (the assembler) the table is referenced and an executable file that contains the opcodes and operands is created (this is the machine code). The machine code program is then loaded into the computers memory and this program is then executed

  • @totallynotbluu
    @totallynotbluu 4 роки тому

    How does one find opcodes in an exe file?

    • @johnphilipjones
      @johnphilipjones  4 роки тому

      You would typically write a machine code program in assembly language. The assembly language is then converted to machine code and stored in a file. The file content are then loaded into RAM to be executed. It is a case of locating the op code of the first assembly language instruction. Every assembly language instruction has a number of bytes that form the opcode and operand. Once you find the first op code you can count the number of bytes to the start of the next instruction. This will be the op code of the next instruction.
      Best wishes
      Phil

  • @pcuser80
    @pcuser80 7 років тому +1

    The great Z80!

  • @Abdullah_gujjar
    @Abdullah_gujjar Рік тому +1

    Thank you Sir ❤❤

  • @ankitkurup3891
    @ankitkurup3891 8 років тому

    But increment doesn't need alu operation,then why it is a part of execution cycle...

    • @johnphilipjones
      @johnphilipjones  8 років тому +2

      There is always a fetch of the opcode which then needs to be decoded to find out what this instruction (i.e. Opcode) is for. After the decode you are in the execute phase. An execute phase does not always mean that the ALU is used. For example moving data from a register to a memory location is an example of an execute phase.

  • @amanullahchandio2320
    @amanullahchandio2320 2 роки тому +1

    Thank you so much sir

  • @johnphilipjones
    @johnphilipjones  11 років тому +2

    Hello Hamza,
    I am developing videos on Python at the moment. But will add some on assembly late next year.
    Best wishes
    Phil

  • @oscarepoant
    @oscarepoant 5 років тому

    A instruction has to be in program memory, doesn't it?

    • @johnphilipjones
      @johnphilipjones  5 років тому

      Yes the instructions are in the computers memory. They are fetched from the memory. See the video at the following link: www.johnphilipjones.com/video-fetch-decode-execute-cycle.html

  • @dimitriosdesmos4699
    @dimitriosdesmos4699 8 років тому +2

    Great stuff exactly what I wanted to form good foundations

  • @tobiasfurlan4812
    @tobiasfurlan4812 2 роки тому +1

    Cheers man

  • @victorx4648
    @victorx4648 5 років тому +1

    Good old Z80 assembly.

  • @sirlottawin
    @sirlottawin 8 років тому +1

    Thank you so very much!

  • @tamimayan2028
    @tamimayan2028 28 днів тому

    1.does assembly language allow you to do things you can’t in a higher level language?
    2. Suggest me some books for assembly language

    • @johnphilipjones
      @johnphilipjones  26 днів тому

      Assembly language does offer some unique capabilities that higher-level languages might not provide. Here are a few key points:
      Direct Hardware Access: Assembly language allows you to interact directly with the hardware, giving you control over specific CPU instructions and memory addresses. This level of control is often necessary for writing device drivers or real-time systems.
      Performance Optimization: Because you can write instructions that are executed directly by the CPU, you can optimize your code for maximum performance. This is particularly useful in scenarios where every millisecond counts, such as in embedded systems or high-frequency trading applications.
      Minimal Overhead: Higher-level languages often introduce some overhead due to abstractions and additional layers of code. Assembly language, being closer to machine code, has minimal overhead, which can be crucial in resource-constrained environments.
      Learning and Debugging: Understanding assembly language can provide deeper insights into how computers work at a fundamental level. It can also be helpful for debugging, as you can see exactly what the CPU is doing at any given moment.
      However, it's worth noting that higher-level languages are generally more productive and easier to maintain, as they abstract away many of the complexities involved in programming at the hardware level. They also come with extensive libraries and frameworks that can speed up development.

    • @tamimayan2028
      @tamimayan2028 26 днів тому

      @johnphilipjones is it true that if i know assembly language, every software/ programing language will be open source for me in that spacific computer

    • @johnphilipjones
      @johnphilipjones  26 днів тому

      @@tamimayan2028 Knowing assembly language can give you a deeper understanding of how software interacts with the hardware, and it can be incredibly powerful for low-level programming and system optimization. However, it doesn't necessarily mean that all software or programming languages will be open source or accessible to you on that specific computer.
      Here are a few key points to consider:
      1. **Understanding Machine Code**:
      - Assembly language is a low-level programming language that is closely related to machine code. If you understand assembly, you can read and potentially modify machine code, which is the lowest level of code executed by the computer's CPU.
      2. **Access to Source Code**:
      - Open-source software means that the source code is freely available for anyone to view, modify, and distribute. Understanding assembly language doesn't grant you access to closed-source software. If a program is closed-source, its source code is not publicly available regardless of your knowledge of assembly.
      3. **Reverse Engineering**:
      - Knowledge of assembly can help you reverse engineer software, which means analyzing a program's binary code to understand its functionality. While this can be useful for debugging or security research, it's important to note that reverse engineering closed-source software can violate licensing agreements and intellectual property laws.
      4. **Programming Language Interoperability**:
      - Understanding assembly language can help you write more efficient code in higher-level languages and understand how those languages are translated into machine instructions. However, each programming language has its own syntax and semantics, and being proficient in assembly doesn't automatically make you proficient in all other programming languages.
      In summary, knowing assembly language can significantly enhance your understanding of how software works at a fundamental level and help you with tasks like optimization and reverse engineering. However, it doesn't provide automatic access to all software or make every programming language open source. Respecting intellectual property and software licenses is crucial.

  • @shikhasingh6865
    @shikhasingh6865 6 років тому

    can you explain this to me for 8086 instruction MOV CH,BL

    • @johnphilipjones
      @johnphilipjones  6 років тому

      Sorry I have never coded the 8086 so not sure what this instruction does.
      Best wishes
      Phil

  • @fakeapplestore4710
    @fakeapplestore4710 8 років тому +1

    yay! what a nice video

    • @awkb777
      @awkb777 7 років тому

      let me know if you have any questions

  • @allenlin3136
    @allenlin3136 9 років тому +1

    It really helps. Thank you.

  • @173028718
    @173028718 8 років тому +1

    Thanks a lot , Sir.

  • @tahir1156
    @tahir1156 2 роки тому +1

    Brilliant

    • @johnphilipjones
      @johnphilipjones  2 роки тому

      Thank you for your positive comment it is appreciated.
      Best wishes
      Phil
      (John Philip Jones)

  • @unlokia
    @unlokia 7 років тому +1

    WOW, so easy! You've earned all your subs, and now you've got another one... ME! :) God bless you and thank you, have an amazing, prosperous life :))
    Matthew, Northants.

    • @johnphilipjones
      @johnphilipjones  3 роки тому

      Thank you for your generous comments.
      Best wishes
      Phil

  • @MrZacsim
    @MrZacsim 10 років тому

    Very good.

  • @guliyevshahriyar
    @guliyevshahriyar 2 роки тому +1

    thanks.