Compare commits

...

No commits in common. "20230701" and "main" have entirely different histories.

41730 changed files with 616240 additions and 133738 deletions

6
.gitignore vendored
View file

@ -1,3 +1,9 @@
/*.ys
/Cache/
/Meta/
/rosettacode.log
/entry
/pick
/random-clojure-task
/.clj-kondo/
/.lsp/

12
Conf/alias.yaml Normal file
View file

@ -0,0 +1,12 @@
# Language name aliases:
lang:
antlang : ant
bash : unix shell
c# : c sharp
c_sharp : c sharp
euler math toolbox : euler
f# : f sharp
free pascal : free pascal/lazarus
f_sharp : f sharp
lazarus : free pascal/lazarus
oberon-2 : oberon

View file

@ -4,6 +4,7 @@
360 Assembly: '.360'
4D: .4d
4DOS Batch: .4dos
4ME: .4me
6502 Assembly: '.6502'
68000 Assembly: '.68000'
6800 Assembly: '.6800'
@ -16,21 +17,25 @@
A+: .a+
AArch64 Assembly: .aarch64
ABAP: .abap
ABC: .abc
ACL2: .acl2
Acornsoft Lisp: .lisp
Action!: .action
ActionScript: .as
Acurity Architect: .acurity
Ada: .ada
Agda: .agda
Ada: .adb
Adina: .adina
Agda2: .agda2
Agda: .agda
Agena: .agena
AHDL: .ahdl
AIDED NATURAL LANGUAGE: .aided
Aikido: .aikido
Aime: .aime
Algae: .algae
ALGOL: .alg
ALGOL 60: .alg
ALGOL 68: .alg
ALGOL: .alg
ALGOL-M: .alg
ALGOL W: .alg
Alice ML: .alice
@ -48,6 +53,7 @@ Anyways: .anyways
Apex: .apex
APL: .apl
App Inventor: .app
Apple: .apple
AppleScript: .applescript
Applesoft BASIC: .basic
Application Master: .app
@ -57,6 +63,8 @@ Arbre: .arbre
Arc: .arc
Arendelle: .arendelle
Argile: .argile
Aria: .aria
ArkScript: .ark
ARM Assembly: .arm
ArnoldC: .arnoldc
Arturo: .arturo
@ -66,35 +74,38 @@ ASP: .asp
AspectC++: .acpp
AspectJ: .aspectj
ASP.Net: .asp
Assembly: .as
Assembly: .asm
AssemblyScript: .asmscript
Astro: .astro
Asymptote: .asymptote
Atari BASIC: .basic
ATS: .ats
AutoHotkey: .ahk
AutoIt: .autoit
AutoLISP: .l
Autohotkey V2: .ahk
AutoHotKey V2: .ahk
AutoIt: .au3
AutoLISP: .lsp
Avail: .avail
AWK: .awk
Axe: .axe
Axiom: .axiom
Axum: .axum
Ayrch: .ayrch
B: .b
B4J: .b4j
B4X: .b4x
Babel: .pb
BabyCobol: .cobol
BaCon: .bacon
Bait: .bait
Ballerina: .ballerina
Bas: .bas
BASIC: .basic
Basic09: .basic
BASIC256: .basic
BASIC: .basic
Batari Basic: .basic
Batch File: .bat
Battlestar: .battlestar
B: .b
BBC BASIC: .basic
Bc: .bc
BCPL: .bcpl
@ -102,6 +113,7 @@ Beads: .beads
Beef: .beef
Beeswax: .beeswax
Befunge: .bf
Berkeley Logo: .logo
Beta: .beta
Biferno: .biferno
Binary Lambda Calculus: .blc
@ -123,31 +135,37 @@ Bracmat: .bracmat
Brainf***: .bf
Brat: .brat
Brlcad: .brlcad
Bruijn: .bruijn
Burlesque: .blq
C++: .cpp
C: .c
C0H: .c0h
C1R: .c1r
C2: .c2
C3: .c3
CafeOBJ: .cafeobj
Calc: .calc
Calcscript: .calc
Caml: .caml
Casio BASIC: .basic
Cat: .cat
CB80: .cb80
CBASIC: .basic
C: .c
C++/CLI: .cpp
C++: .cpp
Cduce: .cduce
Cecil: .cecil
Ceylon: .ceylon
CFEngine: .cfengine
Chapel: .chapel
Chapel: .chpl
Chef: .chef
Cherrycake: .cherrycake
Chipmunk Basic: .basic
CHR: .chr
ChucK: .chuck
Cilk++: .cilk++
Cilk: .cilk
Cind: .cind
CJam: .cjam
Clarion: .clarion
Clay: .clay
Clean: .clean
@ -158,7 +176,7 @@ CLIPS: .clips
Clojure: .clj
CLU: .clu
CMake: .cmake
COBOL: .cobol
COBOL: .cob
Cobra: .cobra
Coco: .coco
Coconut: .coconut
@ -171,18 +189,19 @@ Common Lisp: .lisp
Component Pascal: .pas
Computer/zero Assembly: .0asm
ContextFree: .cf
Convex: .convex
Coq: .coq
Corescript: .core
Cowgol: .cowgol
Crack: .crack
Craft Basic: .basic
Creative Basic: .basic
Crystal: .crystal
Crystal: .cr
C sharp: .cs
C Shell: .csh
Cubescript: .cube
Curry: .curry
D: .d
Curto: .curto
Dafny: .dafny
Dao: .dao
Dart: .dart
@ -191,8 +210,9 @@ DataWeave: .dw
DBL: .dbl
Dc: .dc
DCL: .dcl
D: .d
DDNC: .ddnc
Delphi: .delphi
Delphi: .pas
Deluge: .deluge
DeviousYarn: .dy
DIBOL-11: .dibol-11
@ -204,18 +224,23 @@ DMS: .dms
Dodo0: .dodo0
Draco: .draco
Dragon: .dragon
Dragonstone: .dragonstone
DreamBerd: .dreamberd
Dt: .dt
DuckDB: .duckdb
DUP: .dup
DWScript: .dw
Dyalect: .dyalect
Dylan: .dylan
Dylan.NET: .dylan
E: .e
EasyLang: .easy
EC: .ec
EchoLisp: .l
ECL: .ecl
Ecstasy: .ecstasy
Ed: .ed
EDSAC order code: .edsac
E: .e
Eero: .eero
Efene: .efene
Egel: .egel
@ -228,10 +253,10 @@ Elan: .elan
ElastiC: .elastic
Elena: .elena
Elisa: .elisa
Elixir: .elixir
Elixir: .ex
ELLA: .ella
Elm: .elm
Emacs Lisp: .l
Emacs Lisp: .el
EMal: .emal
Emojicode: .emojicode
Enguage: .enguage
@ -242,27 +267,29 @@ ERRE: .erre
Es: .es
ESQL: .esql
Euler: .euler
Euphoria: .euphoria
Euphoria: .eu
Evaldraw: .evaldraw
Excel: .excel
Explore: .explore
Extended BrainF***: .ebf
Extended Color BASIC: .basic
Ezhil: .ezhil
F: .f
Factor: .factor
Falcon: .falcon
'FALSE': .false
Fan: .fan
Fancy: .fancy
Fan: .fan
Fantom: .fantom
FAUST: .faust
FBSL: .fbsl
Fe: .fe
FeatureC++: .cpp
Fe: .fe
Felix: .felix
Fennel: .fennel
Ferite: .ferite
Fermat: .fermat
Fexl: .fexl
F: .f
Fhidwfe: .fhidwfe
Fish: .fish
FLORA-2: .flora2
@ -276,7 +303,6 @@ FP: .fp
FPI: .fpi
FreeBASIC: .basic
FreeMat: .freemat
Free Pascal: .pas
Free Pascal/Lazarus: .pas
Frege: .frege
Friendly interactive shell: .fish
@ -284,8 +310,10 @@ Frink: .frink
FRISC Assembly: .frisc
F Sharp: .fs
FTCBASIC: .basic
FuncSug: .funcsug
FunL: .funl
Furor: .furor
FurryScript: .furryscript
Futhark: .futhark
FutureBasic: .basic
FUZE BASIC: .basic
@ -305,15 +333,17 @@ GFA Basic: .basic
G-fu: .gfu
Glagol: .glagol
GLBasic: .basic
Gleam: .gleam
Glee: .glee
Global Script: .global
GlovePIE: .glovepie
GLSL: .glsl
GML: .gml
Gnuplot: .gnuplot
Goaldi: .goaldi
Goboscript: .gobo
Go!: .go
Go: .go
Goaldi: .goaldi
Golfscript: .golf
Golo: .golo
Goo: .goo
@ -330,7 +360,7 @@ Halon: .halon
Harbour: .harbour
Hare: .hare
Haskell: .hs
Haxe: .haxe
Haxe: .hx
Heron: .heron
Hexiscript: .hexi
HicEst: .hicest
@ -338,19 +368,22 @@ HLA: .hla
HolyC: .holyc
Hoon: .hoon
Hope: .hope
Hopper: .hopper
HPPPL: .hpppl
HQ9+: .hq9+
Huginn: .huginn
Hy: .hy
HyperTalk: .ht
I: .i
Icon: .icon
IDL: .idl
Idris: .idris
I: .i
Imp77: .imp77
Inform 6: '.inf'
Inform 7: '.inf'
Informix 4GL: .4gl
Inko: .inko
Insitux: .insitux
Integer BASIC: .basic
Intercal: .ical
Io: .io
@ -360,18 +393,19 @@ Iptscrae: .iptscrae
Isabelle: .isabelle
IS-BASIC: .basic
IWBASIC: .basic
J: .j
Jabaco: .jabaco
Jack: .jack
Jacquard Loom: .jacquard
Jactl: .jactl
Jakt: .jakt
JAMES II/Rule-based Cellular Automata: .james
Janet: .janet
Java: .java
JavaFX Script: .javafx
Java: .java
JavaScript: .js
JCL: .jcl
Jinja: .jinja
J: .j
JoCaml: .jocaml
JOVIAL: .jovial
Joy: .joy
@ -380,31 +414,34 @@ JScript.NET: .jscript
JSE: .jse
Jsish: .jsish
JudoScript: .judo
Julia: .julia
K: .k
Julia: .jl
Kabap: .kabap
Kamailio Script: .kamailio
Kantalo: .kantalo
KAP: .kap
Kaya: .kaya
Keg: .keg
KeyList Databasing: .keylist
Kite: .kite
Kitten: .kitten
K: .k
KL1: .kl1
Klingphix: .klingphix
Klong: .klong
Koka: .koka
Komodo: .komodo
KonsolScript: .konsol
Kotlin: .kotlin
Kotlin: .kts
KQL: .kql
Ksh: .ksh
L++: .l++
LabVIEW: .labview
Labyrinth: .labyrinth
Lambda Prolog: .pro
Lambdatalk: .lambdatalk
Lang: .lang
Lang5: .lang5
Lang: .lang
Langur: .langur
Lapyst: .lapyst
Lasso: .lasso
LAST: .last
LaTeX: .tex
@ -430,6 +467,7 @@ Little: .little
Little Man Computer: .lmc
LiveCode: .livecode
LiveScript: .live
L++: .l++
LLP: .llp
LLVM: .llvm
Lobster: .lobster
@ -442,8 +480,8 @@ Lolli: .lolli
Lotus 123 Macro Scripting: .lotus123
LotusScript: .lotus
Lout: .lout
LSE: .lse
LSE64: .lse64
LSE: .lse
LSL: .lsl
LSTS: .lsts
Lua: .lua
@ -457,12 +495,15 @@ M2000 Interpreter: .m2000
M4: .m4
M680x0: .m680x0
MACRO-11: .macro11
Macsyma: .macsyma
MAD: .mad
Make: .make
Malbolge: .malbolge
MANOOL: .manool
Maple: .maple
MAPPER: .mapper
MariaDB: .sql
Mastermind: .mastermind
Mathcad: .mathcad
MathCortex: .mathcortex
Mathematica: .math
@ -480,29 +521,34 @@ Mercury: .mercury
Metafont: .metafont
Metapost: .metapost
MGS: .mgs
Mia: .mia
Microsoft Small Basic: .basic
Min: .min
MINIL: .minil
Minimal BASIC: .basic
MiniScript: .mini
MiniZinc: .minizinc
Min: .min
MIPS Assembly: .mips
Mirah: .mirah
Miranda: .miranda
MIRC Scripting Language: .mirc
Mirelle: .mirelle
ML: .ml
ML/I: .mli
MLite: .mlite
ML: .ml
MMIX: .mmix
Mn: .mn
Modula-2: .mod2
Modula-3: .mod3
Mojo: .mojo
Mond: .mond
Monicelli: .monicelli
Monkey: .monkey
Monte: .monte
MontiLang: .monti
MOO: .moo
MoonBit: .moonbit
MoonRock: .moonrock
MoonScript: .moon
Morfa: .morfa
Mosaic: .mosaic
@ -541,31 +587,36 @@ Nit: .nit
Niue: .niue
Nix: .nix
NLP++: .nlp++
Nom: .num
NOWUT: .nowut
NQP: .nqp
NS-HUBASIC: .basic
NSIS: .nsis
N/t/roff: .ntroff
Nu: .nu
Nutt: .nutt
Nyquist: .nyquist
OASYS: .oasys
OASYS Assembler: .oasys
OASYS: .oasys
Oberon-07: .oberon
Oberon: .oberon
Oberon-2: .oberon
Objeck: .objeck
ObjectIcon: .oi
Objective-C: .m
Object Pascal Implementations: .pas
Object Pascal: .pas
OCaml: .ocaml
OCaml: .ml
Occam: .occam
Octave: .octave
Odin: .odin
Oforth: .fth
Ol: .ol
Omega: .omega
OmniMark: .xom
Onyx: .onyx
OOC: .ooc
Onyx (wasm): .onyx
OOCalc: .oocalc
OOC: .ooc
OoRexx: .rexx
Opa: .opa
OpenC++: .openc++
@ -581,10 +632,12 @@ Oz: .oz
Palo Alto Tiny BASIC: .basic
Panda: .panda
Panoramic: .panoramic
ParaCL: .paracl
Pare: .pare
PARI/GP: .parigp
Pascal: .pas
PascalABC.NET: .pas
Pascal: .pas
Pascal-P: .pas
PASM: .pasm
PDP-11 Assembly: .pdp11
Pebble: .pebble
@ -593,15 +646,16 @@ Pentium Assembly: .pentium
PeopleCode: .peoplecode
PepsiScript: .pepsi
Peri: .peri
Perl: .pl
Perl5i: .p5i
Perl 6: .pl6
Perl: .pl
Peylang: .peylang
Phix: .phix
Phixmonti: .phixmonti
Phix: .phix
PHL: .phl
PHP: .php
Picat: .picat
Pico-8: .pico8
PicoLisp: .l
Pict: .pict
Piet: .piet
@ -614,12 +668,13 @@ Plain English: .plain
PlainTeX: .tex
Plan: .plan
PL/B: .plb
PL/I: .pli
PL/I-80: .pli
PL/I: .pli
PL/M: .plm
PL/pgSQL: .sql
PL/SQL: .sql
PLUS: .plus
Pluto: .pluto
PLZ/SYS: .plz
Pointless: .pointless
Polyglot: .polyglot
@ -632,55 +687,58 @@ POV-Ray: .povray
PowerBASIC: .basic
Powerbuilder: .powerbuilder
PowerPC Assembly: .ppc
PowerShell: .psh
PowerShell: .ps1
PPL: .ppl
Processing: .processing
Processing Python mode: .processing-py
Processing.R: .processing-r
ProDOS: .dos
Prog8: .prog8
ProgressBASIC: .basic
Prolog: .pro
PROMAL: .promal
PSQL: .psql
Pure: .pure
PureBasic: .basic
Pure Data: .puredata
Pure: .pure
Purity: .purity
Pyret: .pyret
Pyret: .arr
Python: .py
Q: .q
QB64: .qb64
QBasic: .basic
Qi: .qi
.QL: .ql
QL SuperBASIC: .basic
Qore: .qore
Q: .q
Quackery: .quackery
QuakeC: .c
QuickBASIC: .basic
Quill: .quill
Quite BASIC: .basic
Quorum: .quorum
R: .r
Ra: .ra
Racket: .rkt
Raku: .raku
RapidQ: .rapidq
Rapira: .rapira
Ra: .ra
Rascal: .rascal
RASEL: .rasel
RATFOR: .ratfor
Raven: .raven
REALbasic: .basic
Reason: .reason
Reason: .re
Rebol: .rebol
REBOL: .rebol
Red: .red
Reduce: .reduce
Refal: .refal
Relation: .relation
ReScript: .re
ReScript: .res
Retro: .retro
Revolution: .rev
REXX: .rexx
Rhombus: .rhombus
Rhope: .rhope
Rhovas: .rhovas
Ring: .ring
@ -689,26 +747,30 @@ RLaB: .rlab
RLSL: .rlsl
Robotic: .robotic
Rockstar: .rockstar
RPG: .rpg
Rocq: .rocq
Roc: .roc
RPGIV: .rpgiv
RPL: .rpl
RPG: .rpg
RPL/2: .rpl2
RPL: .rpl
R: .r
RTL/2: .rtl2
RTSL: .rtsl
Rubylog: .rubylog
Ruby: .rb
Run BASIC: .basic
Rust: .rust
S++: .s++
Rust: .rs
Rye: .rye
Sage: .sage
Salmon: .salmon
SAS: .sas
SapbotVM: .sapbot
SASL: .sasl
SAS: .sas
Sass/SCSS: .sass
Sather: .sa
S-BASIC: .basic
Scala: .scala
Scheme: .ss
Scheme: .scm
Scilab: .scilab
Scratch: .scratch
ScratchScript: .scratch
@ -720,14 +782,15 @@ Seed7: .seed7
Self: .self
SenseTalk: .sensetalk
SequenceL: .sequencel
SETL: .setl
Setl4: .setl4
Set lang: .set
SETL: .setl
Shale: .shale
SheerPower 4GL: .4gl
Shen: .shen
Shiny: .shiny
Sidef: .sidef
SIL: .sil
SimpleCode: .simplecode
SimpleLang: .simple
SIMPOL: .simpol
@ -744,8 +807,8 @@ Smalltalk: .st
Smart BASIC: .basic
SMEQL: .smeql
SmileBASIC: .basic
Snobol: .sno
SNOBOL4: .sno
Snobol: .sno
SNUSP: .snusp
Soar: .soar
Soda: .soda
@ -753,20 +816,22 @@ SoneKing Assembly: .soneking
SPAD: .spad
SPARC Assembly: .sparc
SparForte: .sparforte
SPARK: .spark
Sparkling: .sparkling
SPARK: .spark
Spin: .spin
SPL: .spl
SPSS: .spss
SQL: .sql
SQL PL: .sql
SQL: .sql
Squirrel: .nut
S++: .s++
SSEM: .ssem
Standard ML: .ml
Star: .star
Stata: .stata
Stax: .stax
StreamIt: .streamit
Stringle: .stringle
Suneido: .suneido
Superbase BASIC: .basic
SuperCollider: .sc
@ -780,14 +845,15 @@ SystemVerilog: .v
TailDot: .taildot
Tailspin: .tailspin
TAL: .tal
TAV: .tav
Tbas: .tbas
Tcl: .tcl
TechBASIC: .basic
Teco: .teco
TeLa: .tela
Tern: .tern
Terra: .terra
Terraform: .terraform
Terra: .terra
TestML: .tml
Thistle: .thistle
Thyrd: .thyrd
@ -795,6 +861,7 @@ TI-57: .ti57
TI-83 BASIC: .basic
TI-83 Hex Assembly: .asm
TI-89 BASIC: .basic
TI BASIC: .basic
Tiny BASIC: .basic
Tiny Craft Basic: .basic
TIS-100: .tis100
@ -811,6 +878,7 @@ Transact-SQL: .sql
Transd: .transd
TransFORTH: .fth
Trith: .trith
TRS-80 BASIC: .basic
True BASIC: .basic
TSE SAL: .tse
Turbo-Basic XL: .basic
@ -822,32 +890,34 @@ TXR: .txr
Typed Racket: .rkt
TypeScript: .ts
UC++: .uc++
Uiua: .uiua
Ultimate++: .ultimate++
Unicon: .unicon
Uniface: .uniface
Unison: .unison
Unison: .u
UnixPipes: .up
UNIX Shell: .sh
Unlambda: .unlambda
Ursa: .ursa
Ursalang: .ursa
Ursala: .ursala
Ursa: .ursa
UScript: .u
UserRPL: .rpl
UTFool: .utfool
V: .v
Uxntal: .uxnatl
Vala: .vala
Vale: .vale
VAX Assembly: .vax
VB6: .vb6
VBA: .vba
VBScript: .vb
VBScript: .vbs
Vedit macro language: .vedit
Verbexx: .verbexx
Verilog: .v
VHDL: .vhdl
VHDL: .vhd
Vim Script: .vim
Visual Basic: .vb
Visual Basic .NET: .vb
Visual Basic: .vb
Visual FoxPro: .fvp
Visual Objects: .vobj
Visual Prolog: .pro
@ -856,7 +926,10 @@ Vorpal: .vorpal
Vox: .vox
VRML: .vrml
VTL-2: .vtl-2
V: .v
V (Vlang): .v
Vyxal: .vyxal
Waduzitdo: .waduzitdo
Wart: .wart
WDTE: .wdte
WebAssembly: .wasm
@ -878,31 +951,32 @@ XBase: .xbase
XBasic: .basic
XBS: .xbs
XEec: .xeec
XL: .xl
XLISP: .l
XL: .xl
Xojo: .xojo
XPath 2.0: .xpath
XPL0: .xpl0
XProc: .xproc
XProfan: .xprofan
XQuery: .xquery
XS: .xs
XSLT: .xslt
X-script: .x
XSLT 1.0: .xslt
XSLT 2.0: .xslt
XSLT: .xslt
XS: .xs
XTalk: .xtalk
XUL: .xul
Ya: .ya
Yabasic: .basic
Yacas: .yacas
YAMLScript: .ys
Ya: .ya
Yorick: .yorick
Z80 Assembly: .z80
ZED: .zed
Zig: .zig
Zkl: .zkl
Zoea: .zoea
Zoea Visual: .zoea
Zoea: .zoea
Zonnon: .zonnon
Zoomscript: .zoom
ZPL: .zpl

View file

@ -1 +0,0 @@
../../Task/Bioinformatics-base-count/11l

View file

@ -1 +0,0 @@
../../Task/Comments/11l

View file

@ -1 +0,0 @@
../../Task/List-comprehensions/11l

View file

@ -1 +0,0 @@
../../Task/Meissel-Mertens-constant/11l

View file

@ -1 +0,0 @@
../../Task/Miller-Rabin-primality-test/11l

View file

@ -0,0 +1 @@
../../Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/11l

View file

@ -0,0 +1 @@
../../Task/Set-right-adjacent-bits/11l

View file

@ -1 +0,0 @@
../../Task/Sorting-Algorithms-Circle-Sort/11l

View file

@ -1,3 +1,6 @@
{{stub}}{{language|4D}}{{IDE}}'''4D''' (or '''4th Dimension''') is a database management system and [[:Category:Integrated Development Environments|integrated development environment]] authored by Laurent Ribardière in 1984.
{{stub}}
{{language|4D
|site=https://us.4d.com/
}}{{IDE}}'''4D''' (or '''4th Dimension''') is a database management system and [[:Category:Integrated Development Environments|integrated development environment]] authored by Laurent Ribardière in 1984.
==Citations==
*[[wp:4th_Dimension_%28Software%29|Wikipedia:4th Dimension (Software)]]

7
Lang/4ME/00-LANG.txt Normal file
View file

@ -0,0 +1,7 @@
{{language|4ME
|site=https://thevitebsk.github.io/4ME.by/}}
4ME is a programing language created by [[User:Gaham]] implemented in 04.07.2024 MSK
==See Also==
* [https://esolangs.org/wiki/4ME 4ME in Esolangs.org]
* [https://github.com/Thevitebsk/4me/ Github repo]
[[Category:Programming paradigm/Concatenative]]

2
Lang/4ME/00-META.yaml Normal file
View file

@ -0,0 +1,2 @@
---
from: http://rosettacode.org/wiki/Category:4ME

View file

@ -131,6 +131,29 @@ This flag is set if the <code>BRK</code> command was executed. The BRK basically
* Set with: <code>BRK</code>
* Cleared with: <code>RTI</code>
* There are no branches associated with this command.
This flag is used only for differentiating a <code>BRK</code> from an hardware <code>IRQ</code>
<syntaxhighlight lang="6502asm">IRQ:
STA saveAccumulator ; save accumulator
PLA ; get flags
STA saveFlags ; save flags
AND #$10 ; check "break" flag
BNE IRQ_fromBreak ; if(break flag set){ goto IRQ_fromBreak; }
JMP IRQ_fromHardware ; else{ goto IRQ_fromInterrupt; }
IRQ_fromBreak:
LDA saveFlags ; load flags from temp address
PHA ; restore flags to stack
LDA saveAccumulator ; restore accumulator
;...
RTI ; return from interrupt
IRQ_fromInterrupt:
LDA saveFlags ; load flags from temp address
PHA ; restore flags to stack
LDA saveAccumulator ; restore accumulator
;...
RTI ; return from interrupt
</syntaxhighlight>
<br><br>
===Decimal===

View file

@ -0,0 +1 @@
../../Task/N-queens-problem/6502-Assembly

View file

@ -3,31 +3,36 @@
{{language}}
68000 assembly is the assembly language used for the Motorola 68000, or commonly known as the 68K. It should not be confused with the 6800 (which predates it). The Motorola 68000 is a big-endian processor with full 32-bit capabilities (despite most systems that use it being considered 16-bit.) It was used in many computers such as the Amiga or the Canon Cat, as well as game consoles such as the Sega Genesis and Neo Geo.
==Architecture Overview==
===Big-Endian===
The 68000, unlike most processors of its era, is big-endian. This means that bytes are stored from left to right. The example below illustrates this concept:
<lang 68000devpac>MOVE.L #$12345678,$100000 ;store the hexadecimal numeral #$12345678 at memory address $100000
<syntaxhighlight lang="68000devpac">
MOVE.L #$12345678,$100000 ;store the hexadecimal numeral #$12345678 at memory address $100000
</syntaxhighlight>
<pre>
;hexdump of $100000:
;$100000 = $12
;$100001 = $34
;$100002 = $56
;$100003 = $78</lang>
;$100003 = $78
</pre>
On a little-endian processor such as in [[x86 Assembly]], the order of the bytes would be reversed, i.e.:
<lang asm>;hexdump of $100000
<pre>
;hexdump of $100000
;$100000 = $78
;$100001 = $56
;$100002 = $34
;$100003 = $12</lang>
;$100003 = $12
</pre>
This difference isn't usually relevant in the majority of situations, so don't concern yourself too much. It's much more important when doing [[6502 Assembly]] where registers are smaller than the address space.
The main difference is that if you wanted to access this value as a byte or word it would be at a different address, whereas with a little endian architecture it is at the same address.
===Notation Conventions===
How you write the source code depends on your assembler and the syntax it uses. This page is written using Motorola syntax but there is also Milo syntax which has different conventions.
How you go about defining numbers or text in your code varies wildly between assemblers. I'm using VASM and these are the rules I have to follow, but your assembler may be different.
How you go about defining numbers or text in your code varies wildly between assemblers.
* A number with a # in front represents a constant, literal value. For example, the 3 in <code>MOVE.B #3,D0</code> represents the number 3.
@ -45,72 +50,88 @@ How you go about defining numbers or text in your code varies wildly between ass
* The operand before the comma is the "source", and the operand after is the "destination." For example, <code>MOVE.L D3,D2</code> takes the value in D3 and stores it into D2, not the other way around. This is the opposite of x86 and ARM, which have the source on the right and the destination on the left.
Data blocks, on the other hand, begin with <code>DC.B</code>, <code>DC.W</code>, or <code>DC.L</code> and each represents a constant numeric value. Strangely, you do NOT prefix these with # to signify them as constants (doing so will cause an error on most assemblers). However, you can use the $ or % modifiers to denote hexadecimal or binary.
Data blocks, on the other hand, begin with <code>DC.B</code>, <code>DC.W</code>, or <code>DC.L</code> and each represents a constant numeric value. You do NOT prefix these with # to signify them as constants (doing so will cause an error on most assemblers). However, you can use the $ or % modifiers to denote hexadecimal or binary.
Keep in mind that there is no requirement to use hexadecimal, decimal, or binary in your source code. It all gets converted to binary anyway. However, it is recommended to use the notation that is appropriate for how your data is meant to be interpreted, for readability purposes.
===Data Registers===
There are eight 32-bit data registers on the 68000, numbered D0-D7. As the name implies, these are designed to hold data. Much like in [[ARM Assembly]], each one is identical in terms of which commands it can use. A command that can be used for D0 can be used for any other D-register.
<lang 68000devpac>MOVE.B #$FF,D0 ;move the hexadecimal value 0xFF into the bottom byte of D0.
ADD.W #$8000,D4 ;add hexadecimal 0x8000 to the value stored in D4.</lang>
<syntaxhighlight lang="68000devpac">
MOVE.B #$FF,D0 ;move the hexadecimal value 0xFF into the bottom byte of D0.
ADD.W #$8000,D4 ;add hexadecimal 0x8000 to the value stored in D4.
</syntaxhighlight>
===Address Registers===
There are eight of these as well, numbered A0-A7. A7 is reserved as the stack pointer, and is commonly referenced as SP in assemblers. The others are free to use for any purpose. Although these registers are 32-bit, the 68000's address space is 24-bit (ranges from 0x000000 to 0xFFFFFF), so the leftmost byte is ignored. You can do simple math involving these registers but more complicated commands like multiply or divide can only be used with data registers. Address registers are used to contain addresses and extract the values stored within.
====Loading From Memory====
<lang 68000devpac>MOVEA.L #$200000,A2 ;usually these are loaded from a label.
<syntaxhighlight lang="68000devpac">
MOVEA.L #$200000,A2 ;usually these are loaded from a label.
;The hex dump of address $200000: 44 55 66 77
MOVE.L #$00000000,D0
MOVE.B (A2),D0 ;load the byte stored at $200000 into D0. D0 = #$00000044
MOVE.W (A2),D0 ;load the word stored at $200000 into D0. D0 = #$00004455
MOVE.L (A2),D0 ;load the long stored at $200000 into D0. D0 = #$44556677
MOVE.L D2,(A5) ;store the contents of D2 into the memory address pointed to by A5.</lang>
MOVE.L D2,(A5) ;store the contents of D2 into the memory address pointed to by A5.
</syntaxhighlight>
Note that it's also possible to transfer values to/from memory directly, without involving address registers at all. For constant memory locations, this is fine. However, the real strength of the address registers is in their pre-decrement and post-increment modes, which constant memory locations cannot use.
<lang 68000devpac>MOVE.L ($00FF0000),D0
<syntaxhighlight lang="68000devpac">
MOVE.L ($00FF0000),D0
MOVE.W D1,($00FFFFFE)
MOVE.W ($00FF0000),($00FF1000)</lang>
MOVE.W ($00FF0000),($00FF1000)
</syntaxhighlight>
The use of parentheses is not required on most assemblers, but can be used as a reminder to someone reading your code that these represent the values stored at the specified memory locations rather than literal numbers.
====Post-Increment====
The post-increment mode is specified by adding a + to the end of parentheses. This means that after the command is done, the address stored in the <b>address register</b> (not the value stored at that address) is increased by the byte length of the command (1 for <code>.B</code>, 2 for <code>.W</code>, 4 for <code>.L</code>).
<lang 68000devpac>MOVEA.L #$00240000,A4 ;load the address $240000 into A4
<syntaxhighlight lang="68000devpac">
MOVEA.L #$00240000,A4 ;load the address $240000 into A4
MOVE.W (A4)+,D0 ;move the word stored at $240000 into D0, then increment to #$240002
MOVE.L (A4)+,D1 ;move the long stored at $240000 into D1, then increment to #$240006
MOVE.L (SP)+,D3 ;pop the top value of the stack into D3</lang>
MOVE.L (SP)+,D3 ;pop the top value of the stack into D3
</syntaxhighlight>
====Pre-Decrement====
The pre-decrement mode is specified by typing a - before the parentheses. This means that before the command is done, the address stored in the address register is decreased by the byte length of the command.
<lang 68000devpac>MOVEA.L #$0024000A,A4 ;load the address $24000A into A4
<syntaxhighlight lang="68000devpac">MOVEA.L #$0024000A,A4 ;load the address $24000A into A4
MOVE.W -(A4),D0 ;move the word stored at $240008 into D0
MOVE.L -(A4),D1 ;move the long stored at $240004 into D1
MOVE.L D2,-(SP) ;push the contents of D2 onto the stack</lang>
MOVE.L D2,-(SP) ;push the contents of D2 onto the stack</syntaxhighlight>
====Address Offsets====
A memory address can be offset by a data register, an immediate value, or both. If a data register is used, only the bottom 2 bytes are considered. In either case, the contents of the data register and/or the immediate value are added to the value stored in the address register, and the value is read from that address at the specified length. The offsets are applied during the calculation only; the actual contents in the address register after the move are unchanged. Using a post-increment or pre-decrement with this addressing mode will only update the address by the specified length, not by the offsets.
<lang 68000devpac>MOVE.B (4,A0,D0),D1 ;The byte at A0+D0+4 is loaded into D1.</lang>
<syntaxhighlight lang="68000devpac">
MOVE.B (4,A0,D0),D1 ;The byte at A0+D0+4 is loaded into D1.
</syntaxhighlight>
It's possible to use the same data register as the offset and the destination. This does not cause any problems whatsoever, as the data register offset is "locked in" before the move, and is only updated after the command fully executes. Using the same command again immediately afterwards will offset based on the new value of that register.
<lang 68000devpac>MOVE.W (6,A0,D0),D0 ;The word at A0+D0+6 is read, then loaded into D0.</lang>
<syntaxhighlight lang="68000devpac">
MOVE.W (6,A0,D0),D0 ;The word at A0+D0+6 is read, then loaded into D0.
</syntaxhighlight>
A very important note is that when using this method with words and longs, the resulting address <b><i>must be even!</i></b> Otherwise the CPU will crash. For <code>MOVE.B</code> it doesn't matter.
====Effective Address====
A calculated offset can be saved to an address register with the <code>LEA</code> command, which stands for "Load Effective Address." [[x86 Assembly]] also has this command, and it serves the same purpose. The syntax for it can be a bit misleading depending on your assembler.
<lang 68000devpac>LEA myData,A0 ;load the effective address of myData into A0
<syntaxhighlight lang="68000devpac">
LEA myData,A0 ;load the effective address of myData into A0
LEA (4,A0),A1 ;load into A1 the effective address A0+4. This looks like a dereference operation but it is not!
MOVE.W (A1),D1 ;dereference A1, loading the value it points to into D1.</lang>
MOVE.W (A1),D1 ;dereference A1, loading the value it points to into D1.
</syntaxhighlight>
This can get confusing, especially if you have tables of pointers. Just remember that <code>LEA</code> cannot dereference an address.
If you don't want to store the effective address in an address register, you can use <code>PEA</code> (push effective address) to put it onto the stack instead.
<lang 68000devpac>LEA myData,A0 ;load the effective address of myData into A0
PEA (4,A0) ;store the effective address of A0+4 onto the stack.</lang>
<syntaxhighlight lang="68000devpac">
LEA myData,A0 ;load the effective address of myData into A0
PEA (4,A0) ;store the effective address of A0+4 onto the stack.
</syntaxhighlight>
====The Stack====
The 68000's stack is commonly referred to as <code>SP</code> but it is also address register <code>A7</code>. This register is handled differently than the other address registers when pushing bytes onto the stack. A byte value pushed onto the stack will be padded to the <b>right</b>. The stack needs to pad byte-length data so that it can stay word-aligned at all times. Otherwise the CPU would crash as soon as you tried to use the stack for anything other than a byte!
@ -124,48 +145,48 @@ The 68000 can work with 8-bit, 16-bit, or 32-bit values. Some commands only work
If you don't specify a length with your command, it usually defaults to word length, but ultimately it depends on the command you are using. (Some commands cannot be used at word length.)
Bytes and words moved into a register are always stored on the right-hand side. For example:
<lang 68000devpac>MOVE.L #$FFFFFFFF,D7
<syntaxhighlight lang="68000devpac">
MOVE.L #$FFFFFFFF,D7
MOVE.B #$00,D7 ;D7 contains #$FFFFFF00
MOVE.W #$2222,D7 ;D7 contains #$FFFF2222</lang>
MOVE.W #$2222,D7 ;D7 contains #$FFFF2222
</syntaxhighlight>
As you can see, the rest of the register is unchanged. (On the ARM, it would turn to zeroes.) This is very important to remember. If your code is doing something unexpected it might be due to the "old" value of the register corrupting another function.
If the given constant is smaller than the length provided, the value is padded to the left with zeroes.
<lang 68000devpac>MOVE.W #$FF,D3 ;D3 = #$xxxx00FF, where x is the previous value of D3.
MOVE.L #0,D3 ;D3 = #$00000000</lang>
<syntaxhighlight lang="68000devpac">
MOVE.W #$FF,D3 ;D3 = #$xxxx00FF, where x is the previous value of D3.
MOVE.L #0,D3 ;D3 = #$00000000
</syntaxhighlight>
Loading immediate values into address registers is different. You can only move words or longer into address registers, and if you move a word, the value is sign-extended. This means that if the top nibble of the word is 8 or greater, the value gets padded to the left with Fs, and is padded with zeroes if the top nibble is 7 or less. If you're adding a constant value less than 7FFF to an address, it's usually safe to use the word length operation, which takes less bytes to encode than the long length version.
<lang 68000devpac>MOVEA.W #$8000,A4 ;A4 = #$FFFF8000. Remember the top byte is ignored so this is the same as #$00FF8000.
MOVEA.W #$7FFF,A3 ;A3 = #$00007FFF</lang>
<syntaxhighlight lang="68000devpac">
MOVEA.W #$8000,A4 ;A4 = #$FFFF8000. Remember the top byte is ignored so this is the same as #$00FF8000.
MOVEA.W #$7FFF,A3 ;A3 = #$00007FFF
</syntaxhighlight>
==The Flags==
The flags are stored in the Condition Code Register, also known as the <code>CCR</code>. The 68000 has no built-in commands like <code>CLC</code> for clearing/setting individual flags. Rather, you can alter them directly with <code>MOVE</code>,<code>AND</code>,<code>OR</code>, and <code>EOR</code>. Unfortunately, this means you'll have to remember which bits represent which flags. Or, if your assembler supports macros, you can define a macro that handles this for you.
The flags update automatically after most operations, and take into consideration the operand sizes when doing so. Check out this example:
<lang 68000devpac>
<syntaxhighlight lang="68000devpac">
MOVE.L #$12FF,D0
ADD.B #1,D0
</lang>
</syntaxhighlight>
Since we used <code>ADD.B</code>, D0 now contains $1200, and the extend, carry, and zero flags are all set. Had we done <code>ADD.W</code>, we would get $1300 in D0 with none of those flags set. The flags are based on what the actual instruction "sees", not the entire register at all times.
* X: The eXtend flag is bit 4 of the CCR, and is similar to the carry flag. It gets set and cleared often for the same reasons and is used with the <code>ADDX</code>, <code>SUBX</code>, <code>NEGX</code>, <code>ROXL</code>, and <code>ROXR</code> commands. Why the 68000 has both this and the carry flag, I still don't know.
* N: The negative flag is bit 3 of the CCR, and is set when the last operation resulted in a "negative" value. What constitutes a negative value depends on the size of the last operation - for <code>.B</code> instructions, $80-$FF. For <code>.W</code> instructions, $8000-$FFFF, and for <code>.L</code> instructions, $80000000-$FFFFFFFF.
* Z: The zero flag is bit 2 of the CCR and works like you would expect - it's set whenever an operation results in zero. Unlike x86 Assembly, this also includes moving 0 directly into a register, clearing a register <b>or memory</b> with <code>CLR</code>, etc.
* V: The overflow flag is bit 1 of the CCR. It is set whenever a math operation results in a value crossing the $7F-$80 boundary. (Wraparound from 00 to FF doesn't count as overflow, but it does set the carry flag.)
* C: The carry flag is bit 0 of the CCR. It is set when a math operation results in a carry or borrow. Rolling over from FF to 00, or a 1 getting "pushed out" via a bit shift or rotate, set the carry flag. When using <code>CMP</code>, the carry flag determines the unsigned magnitude comparison. Carry set is less than, carry clear is greater than or equal.
In truth, the flags are a 16-bit register, of which the CCR is just the "low half". The SR (status register) is the full 16-bit register.
There are a few additional flags in the upper half, which are used by the operating system. You can read these but for the most part you won't need to write to them.
@ -189,13 +210,15 @@ The 68000 supports 7 different interrupts, often called IRQs or Interrupt Reques
==Alignment==
The 68000 can only read or write words and longs at even addresses. Doing so at an odd address will result in the CPU crashing. (Note that reading byte data will not cause a crash regardless of whether it's located at an odd or even address.) This isn't usually a problem, but it can be if the programmer is not careful with the way their data is organized. Consider the following example:
<lang 68000devpac>TestData:
<syntaxhighlight lang="68000devpac">
TestData:
DC.B $02
DC.W $0345
LEA TestData,A0 ;load effective address of TestData into A0.
MOVE.B (A0)+,D0 ;load $02 into D0, increment A0 by 1
MOVE.W (A0)+,D1 ;this crashes the CPU since A0 is now odd</lang>
MOVE.W (A0)+,D1 ;this crashes the CPU since A0 is now odd
</syntaxhighlight>
How was it known that the address was odd at the second instruction? Simple. All instructions take an even number of bytes to encode. So there are only a few ways improper alignment can occur:
* An odd value is loaded into an address register.
@ -205,18 +228,23 @@ How was it known that the address was odd at the second instruction? Simple. All
If the programmer is smart with the way they encode byte-length data they can avoid this problem entirely with little effort.
One way is to separate byte-length data into its own table.
<lang 68000devpac>ByteData:
<syntaxhighlight lang="68000devpac">
ByteData:
DC.B $20,$40,$60,$80
WordData:
DC.W $1000,$2000,$3000,$4000</lang>
DC.W $1000,$2000,$3000,$4000
</syntaxhighlight>
Another way is to pad the data with an extra byte, so that there is an even number of entries in the table. This becomes impractical with large data tables, so the <code>EVEN</code> directive can be placed after a series of bytes. If the byte count is odd, <code>EVEN</code> will pad the data with an extra byte. If it's already even, the <code>EVEN</code> command is ignored. This saves you the trouble of having to count a long series of bytes without worrying about wasting space.
<lang 68000devpac>MyString: DC.B "HELLO WORLD 12345678900000",0
EVEN ;some assemblers require this to be on its own line</lang>
<syntaxhighlight lang="68000devpac">
MyString: DC.B "HELLO WORLD 12345678900000",0
EVEN ;some assemblers require this to be on its own line
</syntaxhighlight>
A third way is to perform a "dummy read." This is when a value is read from an address using pre-decrement or post-increment, with the sole purpose of moving the pointer, and the value being read is of zero interest. This method lets you work with mixed data types in the same table, but it requires the programmer to know in advance where the byte-length data begins and ends.
<lang 68000devpac>TestData:
<syntaxhighlight lang="68000devpac">
TestData:
DC.B $02,$03,$04
DC.W $0345
@ -227,7 +255,8 @@ MOVE.B (A0)+,(A1)+ ;copy $04 to a new memory location
;if we did MOVE.W (A0)+,(A1)+ now we'd crash. First we need to adjust the pointers.
MOVE.B (A0)+,D7 ;dummy read to D7. Now A0 is word aligned.
MOVE.B (A1)+,D7 ;dummy read to D7. Now A1 is word aligned.
MOVE.W (A0)+,(A1)+ ;copy $0345 to a new memory location</lang>
MOVE.W (A0)+,(A1)+ ;copy $0345 to a new memory location
</syntaxhighlight>
Using <code>ADDA.L #1,A0</code> and <code>ADDA.L #1,A1</code> would have worked also, instead of the dummy read. The 68000 gives the programmer a lot of different ways to do a task.

View file

@ -0,0 +1 @@
../../Task/Musical-scale/68000-Assembly

View file

@ -0,0 +1 @@
../../Task/Align-columns/8080-Assembly

View file

@ -0,0 +1 @@
../../Task/Display-a-linear-combination/8080-Assembly

View file

@ -0,0 +1 @@
../../Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/8080-Assembly

View file

@ -0,0 +1 @@
../../Task/Integer-comparison/8080-Assembly

View file

@ -0,0 +1 @@
../../Task/Loops-Infinite/8080-Assembly

View file

@ -0,0 +1 @@
../../Task/McNuggets-problem/8080-Assembly

View file

@ -0,0 +1 @@
../../Task/Ordered-words/8080-Assembly

View file

@ -0,0 +1 @@
../../Task/Repeat-a-string/8080-Assembly

View file

@ -0,0 +1 @@
../../Task/Run-length-encoding/8080-Assembly

View file

@ -0,0 +1 @@
../../Task/Sieve-of-Eratosthenes/8080-Assembly

View file

@ -0,0 +1 @@
../../Task/Square-but-not-cube/8080-Assembly

View file

@ -0,0 +1 @@
../../Task/Twos-complement/8080-Assembly

View file

@ -0,0 +1 @@
../../Task/Zeckendorf-number-representation/8080-Assembly

View file

@ -4,13 +4,13 @@
===Segmented Memory===
The 8086 uses a segmented memory model, similar to the Super Nintendo Entertainment System. Unlike banked memory models used in the Commodore 64 and late NES games, segment addresses are held in <i>segment registers</i>. These segment registers are 16 bit and get left-shifted by 4 and added to the pointer register of interest to determine the memory address to look up. The 8086 has four in total, but only the <code>DS</code> and <code>ES</code> registers can be used by the programmer. (The other two work with the stack pointer and instruction pointer, and are loaded for you.) On the 8086, you can only load segment registers with the value in a data register, or with the <code>POP</code> command. So first you must load a segment into a data register, THEN into a segment register.
<lang asm>;This is NOT valid code!
<syntaxhighlight lang="asm">;This is NOT valid code!
mov ds, @data ;you're trying to move the data segment location directly into DS. You can't!
;This is the proper way:
mov ax, @data ;I chose AX but I could have used BX, CX, or DX.
mov ds, ax ;load DS with the data segment.</lang>
mov ds, ax ;load DS with the data segment.</syntaxhighlight>
It's important to remember the subtle distinction between a ''segment'' and a ''segment register.'' Your program might have labeled ''segments'' such as <code>.data</code> and <code>.code</code>, but in order to properly read from/write to these sections you'll need to load their memory locations into ''segment registers.''
@ -18,17 +18,17 @@ It's important to remember the subtle distinction between a ''segment'' and a ''
There are four data registers: <code>AX</code>, <code>BX</code>, <code>CX</code>, and <code>DX</code>. While most commands can use any of them, some only work with particular data registers. System calls in particular are very specific about which registers can be used for what. On [[MS-DOS]], the <code>AX</code> register is used for selecting the desired interrupt to use with the <code>INT</code> command.
Each data register is 16-bit, but has two eight bit halves ending in H or L, e.g. <code>AH, AL</code>. Instructions can be executed using the whole register or just half of it.
<lang asm>mov ax, 1000h ;move 1000h into AX, or equivalently, move 10h into AH and 00h into AL.</lang>
<syntaxhighlight lang="asm">mov ax, 1000h ;move 1000h into AX, or equivalently, move 10h into AH and 00h into AL.</syntaxhighlight>
Moving a value smaller than 16 bits into <code>?X</code> is the same as moving it into <code>?L</code>, and moving 0 into <code>?H</code>. (? represents the data register of your choice. They are all the same in this regard.)
<lang asm>mov ax,0030h
<syntaxhighlight lang="asm">mov ax,0030h
;is the same as:
mov al, 30h
mov ah, 0h</lang>
mov ah, 0h</syntaxhighlight>
Commands that alter the contents of a single register will not affect the other half.
<lang asm>mov ax,00FFh
inc al</lang>
<syntaxhighlight lang="asm">mov ax,00FFh
inc al</syntaxhighlight>
If we had executed <code>INC AX</code>, then <code>AX</code> would have been incremented to 0x100. Since we only incremented <code>AL</code>, only <code>AL</code> was incremented in this case, and <code>AH</code> '''still equals 0x00!'''
Generally speaking, the 8086's registers serve the following purposes:
@ -42,24 +42,24 @@ When writing to or reading from consecutive sections of memory, it is helpful to
The syntax for offsetting an index register will vary depending on your assembler. Many assemblers will often accept multiple different ways of writing it, and it comes down to personal preference.
<lang asm>mov si, offset MyArray
<syntaxhighlight lang="asm">mov si, offset MyArray
mov bx,2
mov al,[bx+si] ;loads decimal 30 into AL
MyArray:
byte 10,20,30,40,50</lang>
byte 10,20,30,40,50</syntaxhighlight>
===The Stack===
As with [[Z80 Assembly]], you can't push 8-bit registers onto the stack. For data registers, you have to push/pop both halves.
<lang asm>;This is valid code.
<syntaxhighlight lang="asm">;This is valid code.
push ax
push bx
pop bx
pop ax</lang>
<lang asm>;This is NOT valid code.
<syntaxhighlight lang="asm">;This is NOT valid code.
push ah
push al
push bh
@ -69,14 +69,14 @@ push bl
pop bl
pop bh
pop al
pop ah</lang>
pop ah</syntaxhighlight>
As with all processors that use a stack, if you push one or more registers and want to restore the backed-up values correctly, you must pop them in the reverse order. You can pop them out of order on purpose to swap registers around. In fact, this is a quick way to move the segment from <code>DS</code> into <code>ES</code>, or vice-versa:
<lang asm>push DS
pop ES ;you can't do "mov es, ds" but you can do this!</lang>
<syntaxhighlight lang="asm">push DS
pop ES ;you can't do "mov es, ds" but you can do this!</syntaxhighlight>
The proper way to use the stack to preserve registers:
<lang asm>
<syntaxhighlight lang="asm">
call foo
mov ax,4C00h
@ -91,7 +91,7 @@ push cx
pop cx
pop bx
pop ax
ret</lang>
ret</syntaxhighlight>
If one of the push/pop commands in the routine above were missing, the <code>RET</code> instruction would not properly return to where it came from. As long as you pop at the end the same number of registers you pushed at the start, the stack is "balanced" and your return instruction will return correctly. This is because <code>RET</code> is actually <code>POP IP</code> (<code>IP</code> being the instruction pointer, which you can think of as what "line" of code the CPU is on.) The CPU assumes the top of the stack is the correct place to return to, but has no way of actually verifying it. If the function you just wrote causes the CPU to crash or jump to a completely different part of the code, there's a good chance you might have forgotten to balance the stack properly.
@ -107,40 +107,40 @@ One other caveat to mention: On early IBM PCs and compatibles, the 8087 was not
===Looping Constructs===
The 8086 has a lot more of these than most CPUs. The most obvious one is <code>LOOP</code>, which will subtract 1 from <code>CX</code>, then jump back to a specified label if <code>CX</code> is nonzero after the subtraction. If <code>CX</code> becomes zero after subtracting 1, then no jump will occur and the instruction pointer simply moves to the next instruction.
<lang asm>mov cx,0100h ;set the loop counter's starting value. This must be outside the loop, otherwise you'll loop forever!
<syntaxhighlight lang="asm">mov cx,0100h ;set the loop counter's starting value. This must be outside the loop, otherwise you'll loop forever!
foo:
;; your code that you want to loop goes here
loop foo </lang>
loop foo </syntaxhighlight>
It's important not to alter <code>CX</code> inside the loop. It's easy to make a mistake like this if you're in a hurry:
<lang asm>foobar:
<syntaxhighlight lang="asm">foobar:
mov cx,1000h
;your code goes here
loop foobar</lang>
loop foobar</syntaxhighlight>
It may not be obvious at first but the above loop will never end. <code>CX</code> decrements to 0x0FFF with the <code>LOOP</code> instruction but the <code>mov cx,1000h</code> was mistakenly placed ''inside'' the loop, resetting the loop counter back to 0x1000, which means no progress is really being made. The correct way to do this is to set the starting loop counter '''outside''' the loop, like so:
<lang asm>mov cx,1000h
<syntaxhighlight lang="asm">mov cx,1000h
foobar:
;your code goes here
loop foobar</lang>
loop foobar</syntaxhighlight>
Sometimes you'll have to change <code>CX</code> during a loop, like if you want to do bit shifts with a shift amount other than 1, for example. There's a simple fix - use the stack to stash and retrieve the loop counter.
<lang asm>mov cx,0100h
<syntaxhighlight lang="asm">mov cx,0100h
foo:
push cx
mov cl,2
ror ax,cl ;starting with the 80186 you don't need CL for bit shifting.
pop cx
loop foo</lang>
loop foo</syntaxhighlight>
By using <code>PUSH CX</code> and <code>POP CX</code>, you can temporarily use <code>CX</code> for something else, as long as you restore it before the <code>LOOP</code> instruction.
You can use other registers as loop counters as well, but not with the <code>LOOP</code> instruction - it's hardcoded to only work with <code>CX</code>. But you can do this:
<lang asm>mov dx,0100h
<syntaxhighlight lang="asm">mov dx,0100h
baz:
;your code goes here
dec dx
@ -148,7 +148,7 @@ jnz baz
; A minor note for advanced programmers:
; If you're expecting the flags to be in a particular state based on the loop body, tough luck!
; They'll only reflect the decrement of DX from 1 to 0 at this point in the code.
; LOOP doesn't change the flags, which makes it more useful for loops meant to compare things.</lang>
; LOOP doesn't change the flags, which makes it more useful for loops meant to compare things.</syntaxhighlight>
Another frequently used looping construct is <code>REP</code>. <code>REP</code> can be combined with certain instructions to repeat that instruction until <code>CX</code> equals zero. However, unlike <code>LOOP</code>, which can be used to repeat a block of instructions, <code>REP</code> can only repeat one. It doesn't work on all instructions, only the "string" instructions which operate on a block of memory. Typically these include <code>MOVSB</code>, <code>LODSB</code>, <code>STOSB</code>, <code>CMPSB</code>, and <code>SCASB</code> (each has a variant that ends in W instead of B, for 16-bit data.) There are also <code>REPZ</code> and <code>REPNZ</code>, which stand for "Repeat if Zero" and "Repeat if Nonzero" respectively. These two only work properly with <code>CMPSB</code> and <code>SCASB</code>, as <code>MOVSB</code>, <code>LODSB</code>, <code>STOSB</code> do not affect the flags. (The CPU doesn't detect whether <code>CX</code> equals zero using the flags, as the flags never reflect this equality to zero like you would expect.)

View file

@ -0,0 +1 @@
../../Task/Angle-difference-between-two-bearings/8th

View file

@ -0,0 +1 @@
../../Task/Environment-variables/8th

1
Lang/8th/Factorial Symbolic link
View file

@ -0,0 +1 @@
../../Task/Factorial/8th

View file

@ -0,0 +1 @@
../../Task/ADFGVX-cipher/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Averages-Median/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Best-shuffle/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Bifid-cipher/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Binary-strings/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Caesar-cipher/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Calculating-the-value-of-e/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Comma-quibbling/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Command-line-arguments/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Compound-data-type/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Conways-Game-of-Life/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Count-occurrences-of-a-substring/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Create-an-HTML-table/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Determine-sentence-type/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Environment-variables/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Fibonacci-n-step-number-sequences/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Fibonacci-sequence/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Filter/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Halt-and-catch-fire/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Hash-from-two-arrays/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Hofstadter-Q-sequence/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Jewels-and-stones/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/K-d-tree/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Keyboard-input-Obtain-a-Y-or-N-response/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Leonardo-numbers/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Letter-frequency/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Logical-operations/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Machine-code/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Magic-8-ball/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Mandelbrot-set/AArch64-Assembly

1
Lang/AArch64-Assembly/Menu Symbolic link
View file

@ -0,0 +1 @@
../../Task/Menu/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Phrase-reversals/AArch64-Assembly

1
Lang/AArch64-Assembly/Pi Symbolic link
View file

@ -0,0 +1 @@
../../Task/Pi/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Quickselect-algorithm/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Read-a-configuration-file/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Repeat-a-string/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Reverse-words-in-a-string/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Rot-13/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Sort-disjoint-sublist/AArch64-Assembly

View file

@ -1 +0,0 @@
../../Task/Sorting-Algorithms-Circle-Sort/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/String-case/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Strip-block-comments/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Strip-comments-from-a-string/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Strip-whitespace-from-a-string-Top-and-tail/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Substitution-cipher/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Twos-complement/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Update-a-configuration-file/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Vigen-re-cipher/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Vigen-re-cipher-Cryptanalysis/AArch64-Assembly

View file

@ -0,0 +1 @@
../../Task/Visualize-a-tree/AArch64-Assembly

View file

@ -1,2 +1,14 @@
{{stub}}{{language|site=http://www.sdn.sap.com/irj/sdn/abap}}
ABAP (Advanced Business Application Programming) is a programming language developed by the german software vendor SAP. It is mainly used to build high performance business applications.
{{stub}}{{language
|site=http://www.sdn.sap.com/irj/sdn/abap
|safety=safe
|strength=strong
|compat=nominative
|checking=static
|tags=abap}}
ABAP (Advanced Business Application Programming) is a programming language developed by the german software vendor SAP. It is mainly used to build high performance business applications.
==Citation==
*[https://en.wikipedia.org/wiki/ABAP]
[[Category:Programming paradigm/Object-oriented]]
[[Category:Programming paradigm/Imperative]]

18
Lang/ABC/00-LANG.txt Normal file
View file

@ -0,0 +1,18 @@
{{language
|exec=interpreted
|site=https://homepages.cwi.nl/~steven/abc/
|strength=strong
|safety=safe
|express=implicit
|checking=dynamic
|parampass=value, reference
|gc=yes}}{{language programming paradigm|Dynamic}}{{language programming paradigm|Imperative}}
'''ABC''' is a programming language and development environment developed for teaching purposes at the National Research Institute for Mathematics and Computer Science in the Netherlands in the late 80s. It was meant to be a replacement for BASIC in teaching programming to students. The language was meant to be used interactively. Instead of traditional source files, the environment uses workspaces, though the UNIX version does have (rather minimal) script support. Function definitions and global variables persist from session to session without the user having to explicitly save or load them. The environment furthermore includes autocompletion and a syntax-aware editor. There is no supported way to access the underlying OS or file system directly. The tight integration between the language implementation and the IDE turned out to be a barrier to expansion, and the language was largely abandoned in the early 90s.
There is an unfortunate bug in the official interpreter: it switches to the alternate terminal screen even when running a non-interactive script, resulting in the output being invisible. A workaround is to specify a terminal type that does not support it, e.g. <tt>TERM=vt100 abc script.abc</tt>.
==References==
* [https://homepages.cwi.nl/~steven/abc/ Official homepage]
* [[wp:ABC_(programming_language)|ABC on Wikipedia]]

2
Lang/ABC/00-META.yaml Normal file
View file

@ -0,0 +1,2 @@
---
from: http://rosettacode.org/wiki/Category:ABC

1
Lang/ABC/100-doors Symbolic link
View file

@ -0,0 +1 @@
../../Task/100-doors/ABC

1
Lang/ABC/100-prisoners Symbolic link
View file

@ -0,0 +1 @@
../../Task/100-prisoners/ABC

1
Lang/ABC/99-bottles-of-beer Symbolic link
View file

@ -0,0 +1 @@
../../Task/99-bottles-of-beer/ABC

1
Lang/ABC/ABC-problem Symbolic link
View file

@ -0,0 +1 @@
../../Task/ABC-problem/ABC

View file

@ -0,0 +1 @@
../../Task/Abundant-deficient-and-perfect-number-classifications/ABC

1
Lang/ABC/Ackermann-function Symbolic link
View file

@ -0,0 +1 @@
../../Task/Ackermann-function/ABC

1
Lang/ABC/Additive-primes Symbolic link
View file

@ -0,0 +1 @@
../../Task/Additive-primes/ABC

1
Lang/ABC/Amicable-pairs Symbolic link
View file

@ -0,0 +1 @@
../../Task/Amicable-pairs/ABC

View file

@ -0,0 +1 @@
../../Task/Arithmetic-derivative/ABC

1
Lang/ABC/Attractive-numbers Symbolic link
View file

@ -0,0 +1 @@
../../Task/Attractive-numbers/ABC

1
Lang/ABC/Benfords-law Symbolic link
View file

@ -0,0 +1 @@
../../Task/Benfords-law/ABC

1
Lang/ABC/Bulls-and-cows Symbolic link
View file

@ -0,0 +1 @@
../../Task/Bulls-and-cows/ABC

Some files were not shown because too many files have changed in this diff Show more