📄 convbas.html
字号:
<!doctype html public "-//W3C//DTD HTML 3.2//EN"><html><head><title>Converting BASIC to assembler</title><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /><meta http-equiv="content-language" content="en" /><meta name="resource-type" content="document"><meta name="copyright" content="This document copyright 2002 by Richard Murray. Use for non-profit and education purposes explicitly granted."><meta name="author" content="Richard Murray"><meta name="rating" content="general"></head><!-- /assembler/convbas.html --><!-- --><!-- (C) Copyright 2002 Richard Murray --><!-- Designed by Richard Murray --><!-- rmurray@heyrick.co.uk --><!-- --><body bgcolor="#f0f0f0" text="#000000" link="#0022dd" vlink="#002288"><table border = "0" width="100%"> <tr> <td align=center width=100> <img src="arm3.gif" width=79 height=78 align = middle> </td> <td> <h1 align="center"><font color="#800080">Converting BASIC to assembler</font></h1> </td> <td align=center width=100> <img src="arm3.gif" width=79 height=78 align = middle> </td></table><p> <p>It is always seen as a fairly major thing to port BASIC programs to assembler; while it is arather deep and irksome thing to do, it must be remembered that the operating system is more thanwilling to help out.<p>Here are some examples...<h2>GET</h2>... <code>SWI "OS_ReadC"</code><p> <p><h2>INKEY</h2>Look at <code>OS_Byte 129</code> to check for a specific key <em>or</em> to read a key within agiven time.<p> <p><h2>INPUT var$</h2><pre> ; read the input ADR R0, buffer MOV R1, #128 ; max. line length is 128 characters MOV R2, #32 ; min. ascii allowed is space (32) MOV R3, #126 ; max. ascii allowed is 126 SWI "OS_ReadLine" ; echo the string (optional) ADR R3, buffer .echo_loop LDRB R0, [R3], #1 ; BASIC's INPUT does an echo of the SWI "OS_WriteC" ; data entered, but you may prefer CMP R0, #13 ; not to do this. Up to you. BNE echo_loop SWI "OS_NewLine" MOV PC, R14 ; now return to caller .buffer EQUS STRING$(128, CHR$(0))</pre><p> <p><h2>SPC</h2>Simply loop while outputting spaces 'n' times.<br>A quick way to output a space is <code>SWI 256+32</code>.<p> <p><h2>TAB(x,y)</h2>Use <code>VDU 31, x, y</code>, like:<pre> MOV R1, #100 ; X MOV R2, #200 ; Y ; do it SWI 256 + 31 ; VDU 31 MOV R0, R1 SWI "OS_WriteC" ; output X MOV R0, R2 SWI "OS_WriteC" ; output Y</pre><p> <p>That simply scratches the surface. You need to stop thinking of 'integers' and 'strings' andinstead think of them as units. For example, a string is simply a sequence of bytes starting at a given location and continuing until a certain condition (such as a terminator byte or lengthcount) is met.<p> <p><hr size = 3><a href="index.html#04">Return to assembler index</a><hr size = 3><address>Copyright © 2002 Richard Murray</address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -