Writing a program for the ALTAIR 8800 computer, 1975 release

Hi, Habr.





In the history of computing, there are certain events that have influenced the course of history. One of these was the emergence of the first mass-produced personal computer.





In those years, computers were used only by scientists and engineers in large enterprises. And then a computer appears, which anyone can buy. The Altair 8800 contained an 8080 processor, 256 bytes of memory in the first version, and was priced below $ 1000 - it was the first successful personal computer to be sold. It was the same computer for which Bill Gates and Paul Allen developed the BASIC language, the computer thanks to which hundreds and thousands of enthusiastic students and schoolchildren came to the world of programming.





Of course, the cheapness came at a price - the first version of ALTAIR did not have a keyboard or a screen, only a toggle switch panel, as in the photo. It became interesting to figure out how to write and run a program on such a PC. For those who want to know how it works, the continuation under the cut.





Code

. ALTAIR 64 , 8080, 2 .





, , 1 5:





; Code segment:

        ORG    0o       ; Set Program Counter to address 0
START:  LDA    I
        MOV    B,A      ; RegB => I (1..N)
        LDA    STEP
        MOV    C,A      ; RegC => STEP (always 1)
        LDA    SUM
        MOV    D,A      ; RegD => SUM (result)
LOOP:     MOV    A,D    ; Move value to Accumulator from Register D (SUM)
          ADD    B      ; Add value in Register B to value in Accumulator
          MOV    D,A    ; Save result back to D     I
          MOV    A,B    ; Mov B to A and decrement it
          SUB    C
          JZ     PEND   ; If A is zero, the calculation is complete
          MOV    B,A    ; If not, continue
          JMP    LOOP     
PEND:   MOV A,D         ; Save result in SUM value
        STA SUM
PWAIT:  JMP PWAIT       ; Nothing to do, infinite loop

; Data segment:

        ORG    200o     ; Set Program Counter to address 200
I:      DB     5o       ; Data Byte at address 200 = 5
STEP:   DB     1o       ; Data Byte at address 201 = 8 (10 octal)
SUM:    DB     0o       ; Data Byte at address 202 = 0

        END             ; End
      
      



, 3 , I, STEP SUM, 1 5 1. B, C D, . JZ (Jump if Zero) , . SUM. , (data segment) , 200o ("o" octet, 8- ).





, , Python :





s = sum(range(6))
      
      



, , - . .





, , . , LDA:





"LDA I", I 200 = 80h, 3A 80 00.





MOV B,A :





01000111b = 47h





- , ( ). , "" , , . :





3a 80 00 47 3a 81 00 4f 
3a 82 00 57 7a 80 57 78 
91 ca 18 00 47 c3 0c 00 
7a 32 82 00 c3 1c 00
      
      



- 38 . MZ, - 0. , , , 40...





ALTAIR 8800, github. :





, ALTAIR . - . , 1 10001000b, DEPOSIT, , DEPOSIT NEXT. , EXAMINE/EXAMINE NEXT. RUN SINGLE STEP.





, DEBUG , hex- . , .





. , 202 = 10000010b, EXAMINE. D7..D0 00001111b = 15, 1 5:





, , . , , , .





1975 BASIC ALTAIR, 1976 "Micro-Soft". IT.





. ALTAIR - , 50 . , . 2 , , , " ".





, ALTAIR . -, "", :





, ALTAIR simh, Linux, :





, .





As usual, good luck to everyone.








All Articles