웹 브라우저에서 Apple II BASIC 프로그램을 작성하는 방법

빈티지 컴퓨터를 프로그래밍하고 싶었던 적이 있습니까? BASIC 프로그래밍 언어를 사용하고 브라우저에서 전설적인 Apple II의 시뮬레이션을 실행하면 쉽습니다! 1970년대 후반과 80년대 초반에 프로그래밍이 어땠는지 훌륭한 아이디어를 얻을 수 있을 것입니다.

물론 실제 Apple II가 있다면 따라할 수도 있습니다. 그렇지 않으면, 우리는 이라는 편리한 Apple II 에뮬레이터를 사용할 것입니다. 사과 ][js created by Will Scullin. We’ll cover the basics of BASIC and run two simple programs.

Why the Apple II Was So Important

Introduced in 1977, the Apple II was launched as part of a class of small, inexpensive computers made possible by microprocessor technology. These personal computers allowed people to own and operate their own machines with relative ease. Prior to this, most computers were expensive and only owned (or shared) by large organizations.

The Apple II stood out because of its low cost and color graphics. It also had seven internal expansion slots that worked with the world’s least expensive floppy disk system at that time, the Disk II. Apple co-founder, Steve Wozniak’s, wizardry with circuit design allowed all these features to fit into a small desktop machine with a lightweight plastic case.

The Apple II was a stunning breakout success for Apple. Over the course of its approximate 16-year lifespan (it was discontinued in 1993), the Apple II platform hosted seven versions of Wozniak’s original computer design. A typical Apple II computer came equipped with 48 or 64 KB of RAM, and a 1.022 MHz 6502 CPU. You could program every model in BASIC.

The Basics of BASIC

From the late 1970s through the early ’80s, most personal computers included a programming language known as BASIC, an acronym for Beginners’ All-purpose Symbolic Instruction Code. BASIC emerged in 1964 on the Dartmouth College Time Sharing System. It quickly became a popular educational tool for computer science due to its ease of use.

  Linux에 Slack을 설치하는 방법

The Apple II shipped with two major versions of BASIC over the years: Wozniak’s Integer BASIC, and Applesoft. Microsoft created Applesoft long before it became famous for Windows.

For this article, we used Applesoft BASIC.

Some Syntax Tips

Every BASIC program on the Apple II is composed of lines of code. Each line has a number, and when a program is RUN, the computer executes each line in numerical order from least to greatest. Each line is entered into computer memory by hitting the Return key.

These three fundamental BASIC commands will always come in handy.

At any time while programming, you can see the contents of your program by typing the LIST command.
To start a new program (erasing the current program from memory), type NEW.
To clear the screen, type HOME.

If you make a mistake while typing in the program, the Apple II will return a “SYNTAX ERROR” upon running the program, and it will include a line number where the error occurred. Simply re-type the offending line, double-checking for possible typos.

Got it? Let’s get started.

Your First Program

First, we’re going to write a very simple program that counts upward forever. It’s a quick way to test if BASIC is working properly on any system.

If you have a real Apple II, power it up. Make sure you use a machine with Applesoft in ROM, such as the Apple II Plus or later, or an original Apple II with the proper language card.

If you’re following along without a real Apple II, open a new browser window to the Apple ][js emulator. Apple ][js uses JavaScript to simulate the circuitry of a real Apple II in software. Basically, you’ll be running an entire Apple II system in a web browser (it works best in Google Chrome).

  Linux에 Libre Office를 설치하는 방법

When you first load the emulator (or boot an Apple II without a floppy disk system), you see a screen like the one shown below.

Press or click “Reset.”

Press

You hear a beep, and then see a “]”라는 메시지와 함께 커서가 깜박입니다.

사과 II

프롬프트에서 다음을 입력하고 각 줄 끝에서 Enter(또는 Return) 키를 누릅니다.

10 X=X+1
20 PRINT X
30 GOTO 10

실수한 경우 키보드의 왼쪽 화살표 키를 사용하여 커서를 뒤로 이동하고 수정하십시오. 입력하는 새 문자는 이전 문자를 덮어씁니다. 전체 줄을 다시 입력할 수도 있습니다.

특정 줄 번호가 있는 코드 줄을 입력할 때마다 BASIC은 이전에 해당 줄 번호에 저장된 내용을 새 입력으로 바꿉니다.

그만큼

Apple II와 같은 이전 시스템에서 BASIC을 사용할 때 10의 배수로 줄 번호를 지정하는 것이 일반적입니다. 이렇게 하면 나중에 필요할 경우 새 코드 줄을 추가할 수 있는 공간이 생깁니다.

그런 다음 LIST를 입력한 다음 Enter(또는 Return) 키를 눌러 프로그램 목록을 봅니다.

그만큼

실수로 필요하지 않은 행으로 끝나는 경우(예: 30 대신 32를 입력한 경우) 행 번호를 입력하고 Enter(또는 Return) 키를 눌러 삭제하십시오.

모든 것이 정상으로 보이면 프로그램을 실행할 때입니다. ]프롬프트에서 RUN을 입력한 다음 Enter(Return) 키를 누릅니다.

프로그램은 영원히 1씩 위로 세고 화면 하단의 새 줄에 각 숫자를 인쇄합니다.

프로그램을 중지하려면 Ctrl+C를 누릅니다. 이렇게 하면 프로그램이 중단되어 실행이 중단됩니다.

ㅏ

그렇다면 이 프로그램은 어떻게 작동합니까? 한 줄씩 정리하자면 다음과 같습니다.

10 X=X+1
20 PRINT X
30 GOTO 10

10행: 여기에서 “X”라는 이름의 변수는 자기 자신에 1을 더한 것과 같다고 프로그램에 알립니다. 프로그램 시작 부분에서 “X”는 0과 같습니다. 따라서 첫 번째 패스에서 프로그램은 0에 1을 더하여 1이 됩니다.
20행: 프로그램은 PRINT 명령을 사용하여 변수 “X”의 내용을 화면에 표시합니다.
30행: GOTO 명령을 사용하여 루프에서 10행으로 프로그램을 다시 보냅니다. 변수 “X”의 값(이제 1씩 증가됨)은 10행에 피드백됩니다. 그런 다음 프로그램은 이 프로세스를 영원히 반복하고 1씩 위쪽으로 세고 각 루프에서 결과를 인쇄합니다.

  온라인 글쓰기를 위한 최소한의 산만함이 없는 도구

간단한 입력 프로그램

이제 프로그램을 입력하고 나열하고 실행하고 중단하는 방법을 배웠으므로 입력한 내용으로 무엇인가를 수행할 수 있는 프로그램을 살펴보겠습니다.

먼저 NEW 를 입력하고 Enter(Return) 키를 누릅니다. 이것은 메모리에서 마지막 프로그램을 지우므로 새로 시작할 수 있습니다.

다음을 한 줄씩 입력한 다음 각 끝에서 Enter(Return) 키를 누릅니다.

10 PRINT "WHAT IS YOUR NAME?"
20 INPUT N$
30 PRINT "HELLO, ";N$

완료되면 프로그램을 나열하여 올바르게 입력했는지 다시 확인하십시오.

다음으로 RUN을 입력하고 Enter(Return)를 눌러 실행합니다. 프로그램에서 물음표( ? )와 함께 입력을 요청합니다. 이름을 입력하고 Enter(Return)를 눌러 질문에 답하십시오.

일종의 신비한 암흑 마법처럼, 프로그램은 당신의 이름을 알고 당신에게 답장을 보냈습니다! 그것은 어떻게 작동 했습니까? 각 행을 살펴보겠습니다.

10 PRINT "WHAT IS YOUR NAME?"
20 INPUT N$
30 PRINT "HELLO, ";N$

10행: 프로그램이 화면에 한 줄의 텍스트를 표시했습니다. 인쇄하려는 텍스트의 모든 줄은 따옴표로 묶어야 합니다.
20행: 프로그램은 사용자에게 INPUT을 요청하고 결과를 N$라는 변수에 저장합니다. 달러 기호는 “문자열”의 약자입니다. 문자를 포함하는 모든 변수는 문자열 유형 변수여야 합니다.
30행: 프로그램은 Hello 다음에 쉼표와 공백을 표시한 다음 변수 N$의 내용을 인쇄했습니다. 세미콜론은 줄 바꿈을 삽입하지 않고 같은 줄에 N$를 인쇄하도록 프로그램에 지시했습니다.

표면 긁기

Apple II 컴퓨터를 사용하는 사람들의 그림

이제 Apple II에서 BASIC을 맛보았으므로 모든 친구에게 구형 컴퓨터를 프로그래밍했다고 말할 수 있습니다! 사실, 당신은 말할 수 있습니다 트위터의 스티브 워즈니악.

Applesoft BASIC에 대해 자세히 알아보려면 다음을 권장합니다. Yuri Yakimenko의 멋진 온라인 튜토리얼입니다. 여기에 있는 것보다 훨씬 더 자세히 설명합니다. 이것도 있어요 편리한 빠른 참조 Applesoft BASIC 명령.

전체 스캔 Apple II 기본 프로그래밍 매뉴얼 1978년부터 사용 가능합니다. 프로그램을 저장하고 로드하는 방법에 대해 자세히 설명합니다.

지난 42년 동안 수천 개의 놀라운 게임과 응용 프로그램이 Applesoft에서 프로그래밍되었으므로 Applesoft로 할 수 있는 작업의 한계는 무한합니다. (사실, 당신의 컴퓨터에 있는 RAM의 양이 한계이지만, 그것은 훨씬 덜 시적입니다.)

Apple II 베테랑 여러분을 위해 BASIC 사용에 대한 귀하의 이야기를 댓글로 듣고 싶습니다. 즐거운 프로그래밍!